github.com/hikaru7719/go@v0.0.0-20181025140707-c8b2ac68906a/test/fixedbugs/issue15091.go (about)

     1  // errorcheck -0 -race
     2  // +build linux,amd64 linux,ppc64le darwin,amd64 freebsd,amd64 netbsd,amd64 windows,amd64
     3  
     4  // Copyright 2016 The Go Authors. All rights reserved.
     5  // Use of this source code is governed by a BSD-style
     6  // license that can be found in the LICENSE file.
     7  
     8  package sample
     9  
    10  type Html struct {
    11  	headerIDs map[string]int
    12  }
    13  
    14  // We don't want to see:
    15  //    internal error: (*Html).xyzzy autotmp_3 (type *int) recorded as live on entry, p.Pc=0
    16  // or (now, with the error caught earlier)
    17  //    Treating auto as if it were arg, func (*Html).xyzzy, node ...
    18  // caused by racewalker inserting instrumentation before an OAS where the Ninit
    19  // of the OAS defines part of its right-hand-side. (I.e., the race instrumentation
    20  // references a variable before it is defined.)
    21  func (options *Html) xyzzy(id string) string {
    22  	for count, found := options.headerIDs[id]; found; count, found = options.headerIDs[id] {
    23  		_ = count
    24  	}
    25  	return ""
    26  }