github.com/markusbkk/elvish@v0.0.0-20231204143114-91dc52438621/pkg/eval/deprecation.go (about) 1 package eval 2 3 import ( 4 "github.com/markusbkk/elvish/pkg/diag" 5 ) 6 7 type deprecationRegistry struct { 8 registered map[deprecation]struct{} 9 } 10 11 func newDeprecationRegistry() deprecationRegistry { 12 return deprecationRegistry{registered: make(map[deprecation]struct{})} 13 } 14 15 type deprecation struct { 16 srcName string 17 location diag.Ranging 18 message string 19 } 20 21 // Registers a deprecation, and returns whether it was registered for the first 22 // time. 23 func (r *deprecationRegistry) register(dep deprecation) bool { 24 if _, ok := r.registered[dep]; ok { 25 return false 26 } 27 r.registered[dep] = struct{}{} 28 return true 29 }