github.com/gopherjs/gopherjs@v1.19.0-beta1.0.20240506212314-27071a8796e4/compiler/natives/src/internal/intern/intern.go (about) 1 //go:build js 2 3 package intern 4 5 var ( 6 eth0 = &Value{cmpVal: "eth0"} 7 eth1 = &Value{cmpVal: "eth1"} 8 ) 9 10 func get(k key) *Value { 11 // Interning implementation in this package unavoidably relies upon 12 // runtime.SetFinalizer(), which GopherJS doesn't support (at least until it 13 // is considered safe to use the WeakMap API). Without working finalizers 14 // using this package would create memory leaks. 15 // 16 // Considering that this package is supposed to serve as an optimization tool, 17 // it is better to make it explicitly unusable and work around it at the call 18 // sites. 19 20 // net/netip tests use intern API with a few fixed values. It is easier to 21 // special-case them here than to override the entire test set. 22 if k.isString && k.s == "eth0" { 23 return eth0 24 } else if k.isString && k.s == "eth1" { 25 return eth1 26 } 27 28 panic("internal/intern is not supported by GopherJS") 29 }