github.com/karrick/go@v0.0.0-20170817181416-d5b0ec858b37/src/cmd/vet/testdata/assign.go (about) 1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // This file contains tests for the useless-assignment checker. 6 7 package testdata 8 9 type ST struct { 10 x int 11 } 12 13 func (s *ST) SetX(x int) { 14 // Accidental self-assignment; it should be "s.x = x" 15 x = x // ERROR "self-assignment of x to x" 16 // Another mistake 17 s.x = s.x // ERROR "self-assignment of s.x to s.x" 18 }