cue: suppress some linter errors

Change-Id: Ic935ae04d2310cbce55838356f566fc8cab2aaa2
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2303
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/cmd/cue/cmd/common.go b/cmd/cue/cmd/common.go
index 236083d..e4e179e 100644
--- a/cmd/cue/cmd/common.go
+++ b/cmd/cue/cmd/common.go
@@ -130,7 +130,7 @@
 	for _, inst := range binst {
 		for _, f := range inst.ToolCUEFiles {
 			if file := inst.Abs(f); !included[file] {
-				ti.AddFile(file, nil)
+				_ = ti.AddFile(file, nil)
 				included[file] = true
 			}
 		}
diff --git a/cue/ast/walk.go b/cue/ast/walk.go
index f11d06f..35c0167 100644
--- a/cue/ast/walk.go
+++ b/cue/ast/walk.go
@@ -39,12 +39,6 @@
 
 // Helper functions for common node lists. They may be empty.
 
-func walkIdentList(v visitor, list []*Ident) {
-	for _, x := range list {
-		walk(v, x)
-	}
-}
-
 func walkExprList(v visitor, list []Expr) {
 	for _, x := range list {
 		walk(v, x)
diff --git a/cue/build/instance.go b/cue/build/instance.go
index 7824b4e..7b3ab18 100644
--- a/cue/build/instance.go
+++ b/cue/build/instance.go
@@ -85,9 +85,8 @@
 	// directory.
 	AllTags []string
 
-	Standard    bool // Is a builtin package
-	Local       bool
-	localPrefix string
+	Standard bool // Is a builtin package
+	Local    bool
 
 	// Relative to Dir
 	CUEFiles        []string // .cue source files
diff --git a/cue/build_test.go b/cue/build_test.go
index fcb7d1e..5ce6a10 100644
--- a/cue/build_test.go
+++ b/cue/build_test.go
@@ -203,7 +203,7 @@
 
 func buildInstance(bi *bimport, p *build.Instance) {
 	for i, f := range bi.files {
-		p.AddFile(fmt.Sprintf("file%d.cue", i), f)
+		_ = p.AddFile(fmt.Sprintf("file%d.cue", i), f)
 	}
 	p.Complete()
 }
diff --git a/cue/instance_test.go b/cue/instance_test.go
index da8569c..2b3405b 100644
--- a/cue/instance_test.go
+++ b/cue/instance_test.go
@@ -108,7 +108,7 @@
 			in := []*build.Instance{}
 			for _, str := range tc.instances {
 				bi := ctx.NewInstance("dir", nil) // no packages
-				bi.AddFile("file", str)
+				_ = bi.AddFile("file", str)
 				in = append(in, bi)
 			}
 			merged := Merge(Build(in)...)
@@ -143,14 +143,14 @@
 			ctx := build.NewContext()
 
 			bi := ctx.NewInstance("main", nil) // no packages
-			bi.AddFile("file", tc.instance)
+			_ = bi.AddFile("file", tc.instance)
 			main := Build([]*build.Instance{bi})
 			if err := main[0].Err; err != nil {
 				t.Fatal(err)
 			}
 
 			bi = ctx.NewInstance("overlay", nil) // no packages
-			bi.AddFile("file", tc.overlay)
+			_ = bi.AddFile("file", tc.overlay)
 
 			overlay := main[0].Build(bi)
 
diff --git a/cue/literal/string.go b/cue/literal/string.go
index 8a44800..8fa52d9 100644
--- a/cue/literal/string.go
+++ b/cue/literal/string.go
@@ -23,7 +23,6 @@
 
 var (
 	errSyntax            = errors.New("invalid syntax")
-	errInvalidString     = errors.New("invalid string")
 	errInvalidWhitespace = errors.New("invalid string: invalid whitespace")
 	errMissingNewline    = errors.New(
 		"invalid string: opening quote of multiline string must be followed by newline")
diff --git a/cue/load/import.go b/cue/load/import.go
index 5de8585..b5961b4 100644
--- a/cue/load/import.go
+++ b/cue/load/import.go
@@ -153,7 +153,7 @@
 		if !filepath.IsAbs(f) {
 			f = filepath.Join(root, f)
 		}
-		p.AddFile(f, nil)
+		_ = p.AddFile(f, nil)
 	}
 	p.Complete()
 	return p
diff --git a/cue/load/loader.go b/cue/load/loader.go
index 74d842f..9060a1c 100644
--- a/cue/load/loader.go
+++ b/cue/load/loader.go
@@ -80,14 +80,6 @@
 	// of that package must not pass resolveImport, because
 	// disallowVendor will reject direct use of paths containing /vendor/.
 	resolveImport = 1 << iota
-
-	// resolveModule is for download (part of "go get") and indicates
-	// that the module adjustment should be done, but not vendor adjustment.
-	resolveModule
-
-	// getTestDeps is for download (part of "go get") and indicates
-	// that test dependencies should be fetched too.
-	getTestDeps
 )
 
 type loader struct {
@@ -157,7 +149,7 @@
 		if !filepath.IsAbs(f) {
 			f = filepath.Join(cfg.Dir, f)
 		}
-		pkg.AddFile(f, nil)
+		_ = pkg.AddFile(f, nil)
 	}
 
 	pkg.Local = true
diff --git a/cue/load/package.go b/cue/load/package.go
index ec817db..54c34b3 100644
--- a/cue/load/package.go
+++ b/cue/load/package.go
@@ -48,8 +48,6 @@
 	)
 }
 
-var foldPath = make(map[string]string)
-
 // safeArg reports whether arg is a "safe" command-line argument,
 // meaning that when it appears in a command-line, it probably
 // doesn't have some special meaning other than its own name.
diff --git a/cue/load/search.go b/cue/load/search.go
index ebb2c72..af48a0b 100644
--- a/cue/load/search.go
+++ b/cue/load/search.go
@@ -157,7 +157,7 @@
 
 	pkgDir := filepath.Join(root, "pkg")
 
-	filepath.Walk(root, func(path string, fi os.FileInfo, err error) error {
+	_ = filepath.Walk(root, func(path string, fi os.FileInfo, err error) error {
 		if err != nil || !fi.IsDir() {
 			return nil
 		}
diff --git a/cue/parser/interface.go b/cue/parser/interface.go
index eea578f..1c37728 100644
--- a/cue/parser/interface.go
+++ b/cue/parser/interface.go
@@ -145,7 +145,7 @@
 	var pp parser
 	defer func() {
 		if pp.panicking {
-			recover()
+			_ = recover()
 		}
 
 		// set result values
@@ -189,7 +189,7 @@
 	var p parser
 	defer func() {
 		if p.panicking {
-			recover()
+			_ = recover()
 		}
 		p.errors.Sort()
 		err = p.errors.Err()
diff --git a/cue/parser/parser.go b/cue/parser/parser.go
index d0a2c63..cee8f7b 100644
--- a/cue/parser/parser.go
+++ b/cue/parser/parser.go
@@ -82,13 +82,6 @@
 	p.next()
 }
 
-type commentList struct {
-	taken      bool // for validation
-	attachTail bool
-	head       *ast.CommentGroup
-	last       *ast.CommentGroup
-}
-
 type commentState struct {
 	parent *commentState
 	pos    int8
@@ -911,10 +904,6 @@
 	return elts
 }
 
-func isClauseStart(tok token.Token) bool {
-	return tok == token.FOR || tok == token.IF // || tok == LET
-}
-
 func (p *parser) parseComprehensionClauses() (clauses []ast.Clause) {
 	// TODO: reuse Template spec, which is possible if it doesn't check the
 	// first is an identifier.
@@ -1252,8 +1241,6 @@
 // ----------------------------------------------------------------------------
 // Declarations
 
-type parseSpecFunction func(iota int) *ast.ImportSpec
-
 func isValidImport(lit string) bool {
 	const illegalChars = `!"#$%&'()*,:;<=>?[\]^{|}` + "`\uFFFD"
 	s, _ := literal.Unquote(lit) // go/scanner returns a legal string literal
diff --git a/cue/parser/parser_test.go b/cue/parser/parser_test.go
index d795f62..053e9b1 100644
--- a/cue/parser/parser_test.go
+++ b/cue/parser/parser_test.go
@@ -15,7 +15,6 @@
 package parser
 
 import (
-	"bytes"
 	"fmt"
 	"strings"
 	"testing"
@@ -423,7 +422,7 @@
 
 	// ParseExpr must not crash
 	for _, src := range valids {
-		parseExprString(src)
+		_, _ = parseExprString(src)
 	}
 }
 
@@ -478,39 +477,6 @@
 	return name
 }
 
-func getField(file *ast.File, fieldname string) *ast.Field {
-	get := func(elts []ast.Decl, name string) *ast.Field {
-		for _, s := range elts {
-			if s, ok := s.(*ast.Field); ok && labelName(s.Label) == name {
-				return s
-			}
-		}
-		return nil
-	}
-	elts := file.Decls
-	var m *ast.Field
-	for _, p := range strings.Split(fieldname, ".") {
-		m = get(elts, p)
-		if v, ok := m.Value.(*ast.StructLit); ok {
-			elts = v.Elts
-		} else {
-			break
-		}
-	}
-	return m
-}
-
-// Don't use CommentGroup.Text() - we want to see exact comment text.
-func commentText(c *ast.CommentGroup) string {
-	var buf bytes.Buffer
-	if c != nil {
-		for _, c := range c.List {
-			buf.WriteString(c.Text)
-		}
-	}
-	return buf.String()
-}
-
 // TestIncompleteSelection ensures that an incomplete selector
 // expression is parsed as a (blank) *SelectorExpr, not a
 // *BadExpr.
diff --git a/encoding/openapi/openapi_test.go b/encoding/openapi/openapi_test.go
index 504b75a..4f0542a 100644
--- a/encoding/openapi/openapi_test.go
+++ b/encoding/openapi/openapi_test.go
@@ -59,11 +59,11 @@
 
 			b, err := Gen(inst, tc.config)
 			var out = &bytes.Buffer{}
-			json.Indent(out, b, "", "   ")
+			_ = json.Indent(out, b, "", "   ")
 
 			wantFile := filepath.Join("testdata", tc.out)
 			if *update {
-				ioutil.WriteFile(wantFile, out.Bytes(), 0644)
+				_ = ioutil.WriteFile(wantFile, out.Bytes(), 0644)
 				return
 			}
 
diff --git a/pkg/encoding/csv/manual.go b/pkg/encoding/csv/manual.go
index 1e2338c..99e2cf1 100644
--- a/pkg/encoding/csv/manual.go
+++ b/pkg/encoding/csv/manual.go
@@ -48,7 +48,7 @@
 				a = append(a, string(b))
 			}
 		}
-		w.Write(a)
+		_ = w.Write(a)
 	}
 	w.Flush()
 	return buf.String(), nil
diff --git a/pkg/text/tabwriter/manual.go b/pkg/text/tabwriter/manual.go
index 4c65af5..42f90aa 100644
--- a/pkg/text/tabwriter/manual.go
+++ b/pkg/text/tabwriter/manual.go
@@ -50,7 +50,7 @@
 			if err := write(i.Value()); err != nil {
 				return "", err
 			}
-			tw.Write([]byte{'\n'})
+			_, _ = tw.Write([]byte{'\n'})
 		}
 	default:
 		return "", fmt.Errorf("tabwriter.Write: unsupported type %v", data.Kind())
diff --git a/pkg/tool/exec/exec.go b/pkg/tool/exec/exec.go
index 9b68797..ad288d1 100644
--- a/pkg/tool/exec/exec.go
+++ b/pkg/tool/exec/exec.go
@@ -54,9 +54,7 @@
 		doc = str
 		list := strings.Fields(str)
 		bin = list[0]
-		for _, s := range list[1:] {
-			args = append(args, s)
-		}
+		args = append(args, list[1:]...)
 
 	case cue.ListKind:
 		list, _ := v.List()