github.com/powerman/golang-tools@v0.1.11-0.20220410185822-5ad214d8d803/go/callgraph/vta/internal/trie/scope.go (about) 1 // Copyright 2021 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 package trie 6 7 import ( 8 "strconv" 9 "sync/atomic" 10 ) 11 12 // Scope represents a distinct collection of maps. 13 // Maps with the same Scope can be equal. Maps in different scopes are distinct. 14 // Each Builder creates maps within a unique Scope. 15 type Scope struct { 16 id int32 17 } 18 19 var nextScopeId int32 20 21 func newScope() Scope { 22 id := atomic.AddInt32(&nextScopeId, 1) 23 return Scope{id: id} 24 } 25 26 func (s Scope) String() string { 27 return strconv.Itoa(int(s.id)) 28 }