mirror of
https://github.com/golang/go
synced 2024-11-18 07:44:51 -07:00
01f8cd246d
They will be deleted from their current homes once this has landed. Changes made to import paths to make the code compile, and to find errchk in the right place in cmd/vet's Makefile. TODO in a later CL: tidy up vet. R=golang-dev, gri CC=golang-dev https://golang.org/cl/9495043
21 lines
486 B
Go
21 lines
486 B
Go
// Copyright 2013 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 useless-assignment checker.
|
|
|
|
// +build vet_test
|
|
|
|
package main
|
|
|
|
type ST struct {
|
|
x int
|
|
}
|
|
|
|
func (s *ST) SetX(x int) {
|
|
// Accidental self-assignment; it should be "s.x = x"
|
|
x = x // ERROR "self-assignment of x to x"
|
|
// Another mistake
|
|
s.x = s.x // ERROR "self-assignment of s.x to s.x"
|
|
}
|