1
0
mirror of https://github.com/golang/go synced 2024-11-18 14:14:46 -07:00
go/cmd/vet/testdata/unused.go
Alan Donovan 4a08fb6fc3 cmd/vet: -unusedresult: report calls of pure functions in expression statements
Change-Id: Ib8b6eaecd56ae15c44fb8ac11c781244964428f1
Reviewed-on: https://go-review.googlesource.com/6661
Reviewed-by: David Symonds <dsymonds@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-04-06 21:44:23 +00:00

30 lines
745 B
Go

// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file contains tests for the unusedresult checker.
package testdata
import (
"bytes"
"errors"
"fmt"
)
func _() {
fmt.Errorf("") // ERROR "result of fmt.Errorf call not used"
_ = fmt.Errorf("")
errors.New("") // ERROR "result of errors.New call not used"
err := errors.New("")
err.Error() // ERROR "result of \(error\).Error call not used"
var buf bytes.Buffer
buf.String() // ERROR "result of \(bytes.Buffer\).String call not used"
fmt.Sprint("") // ERROR "result of fmt.Sprint call not used"
fmt.Sprintf("") // ERROR "result of fmt.Sprintf call not used"
}