From c706731dc74a524c32036060e51c50ccdf81e1d3 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 17 Mar 2020 20:07:08 -0700 Subject: [PATCH] tsweb: add copyright header And fix an unlikely but potential crash. --- tsweb/log.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tsweb/log.go b/tsweb/log.go index dbb9e7b8f..43494b45b 100644 --- a/tsweb/log.go +++ b/tsweb/log.go @@ -1,3 +1,7 @@ +// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + package tsweb import ( @@ -36,8 +40,7 @@ func (m Msg) String() string { } var buf strings.Builder json.NewEncoder(&buf).Encode(m) - ret := buf.String() - return ret[:len(ret)-1] // remove trailing newline + return strings.TrimRight(buf.String(), "\n") } // HTTPError is an error with embedded HTTP response information.