Files
llgo/_demo/go/unique/main.go
xgopilot be766727c1 feat(demo): add go1.23 build tag to unique demo
Added //go:build go1.23 constraint to the unique demo.
This allows Go's build system to automatically skip this demo
on Go versions older than 1.23, avoiding compilation errors
where the unique package doesn't exist.

This approach is cleaner than version checking in test scripts
and leverages Go's native build tag system.

Generated with [codeagent](https://github.com/qbox/codeagent)
Co-authored-by: cpunion <cpunion@users.noreply.github.com>
2025-10-18 01:12:56 +00:00

41 lines
786 B
Go

//go:build go1.23
package main
import "unique"
func main() {
var h1 = unique.Make(int(42))
var h2 = unique.Make(int(42))
if h1 != h2 {
panic("h1 and h2 should be equal")
}
var v1 = h1.Value()
var v2 = h2.Value()
if v1 != v2 || v1 != 42 {
panic("values should be equal to 42")
}
var h3 = unique.Make("hello")
var h4 = unique.Make("hello")
if h3 != h4 {
panic("h3 and h4 should be equal")
}
var s1 = h3.Value()
var s2 = h4.Value()
if s1 != s2 || s1 != "hello" {
panic("values should be equal to 'hello'")
}
var h5 = unique.Make(int(100))
var h6 = unique.Make(int(200))
if h5 == h6 {
panic("h5 and h6 should not be equal")
}
var n1 = h5.Value()
var n2 = h6.Value()
if n1 != 100 || n2 != 200 {
panic("values should be 100 and 200 respectively")
}
}