From 950034db5cca6df75a2cb39c5e2c2e66dc41c534 Mon Sep 17 00:00:00 2001 From: Albert Nigmatzianov Date: Tue, 15 Nov 2016 21:22:43 +0100 Subject: [PATCH] source, tpl: Fix staticcheck complaints tpl/template_funcs.go:1019:3: the surrounding loop is unconditionally terminated source/lazy_file_reader.go:66:5: err != nil is always true for all possible values ([nil:error] != [nil:error]) --- source/lazy_file_reader.go | 3 +-- tpl/template_funcs.go | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/source/lazy_file_reader.go b/source/lazy_file_reader.go index 8ebe8df21..7cc484f0b 100644 --- a/source/lazy_file_reader.go +++ b/source/lazy_file_reader.go @@ -62,8 +62,7 @@ func (l *LazyFileReader) Read(p []byte) (n int, err error) { } l.contents = bytes.NewReader(b) } - l.contents.Seek(l.pos, 0) - if err != nil { + if _, err = l.contents.Seek(l.pos, 0); err != nil { return 0, errors.New("failed to set read position: " + err.Error()) } n, err = l.contents.Read(p) diff --git a/tpl/template_funcs.go b/tpl/template_funcs.go index 281e5cd64..d9b4be990 100644 --- a/tpl/template_funcs.go +++ b/tpl/template_funcs.go @@ -1010,13 +1010,13 @@ func delimit(seq, delimiter interface{}, last ...interface{}) (template.HTML, er } var dLast *string - for _, l := range last { + if len(last) > 0 { + l := last[0] dStr, err := cast.ToStringE(l) if err != nil { dLast = nil } dLast = &dStr - break } seqv := reflect.ValueOf(seq)