{"record":{"id":"4ded23da0d42a523","repo":"tailscale/tailscale","slug":"unimplemented-on-this-goos","errorCode":null,"errorMessage":"unimplemented on this GOOS","messagePattern":"unimplemented on this GOOS","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"derp/xdp/xdp_default.go","lineNumber":19,"sourceCode":"// Copyright (c) Tailscale Inc & contributors\n// SPDX-License-Identifier: BSD-3-Clause\n\n//go:build !linux\n\npackage xdp\n\nimport (\n\t\"errors\"\n\n\t\"github.com/prometheus/client_golang/prometheus\"\n)\n\n// STUNServer is unimplemented on these platforms, see xdp_linux.go.\ntype STUNServer struct {\n}\n\nfunc NewSTUNServer(config *STUNServerConfig, opts ...STUNServerOption) (*STUNServer, error) {\n\treturn nil, errors.New(\"unimplemented on this GOOS\")\n}\n\nfunc (s *STUNServer) Close() error {\n\treturn errors.New(\"unimplemented on this GOOS\")\n}\n\nfunc (s *STUNServer) Describe(descCh chan<- *prometheus.Desc) {}\n\nfunc (s *STUNServer) Collect(metricCh chan<- prometheus.Metric) {}\n\nfunc (s *STUNServer) SetDropSTUN(v bool) error {\n\treturn errors.New(\"unimplemented on this GOOS\")\n}\n\nfunc (s *STUNServer) GetDropSTUN() bool {\n\treturn true\n}\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/tailscale/tailscale/blob/6e0912f97994f927632b34ae9e63b53d6516a6ac/derp/xdp/xdp_default.go#L1-L37","documentation":"derp/xdp provides an eBPF/XDP-accelerated STUN server only on Linux (xdp_linux.go); xdp_default.go is the stub compiled for every other GOOS. Its NewSTUNServer (and Close, SetDropSTUN) return 'unimplemented on this GOOS' so platform-agnostic code fails loudly instead of silently misbehaving.","triggerScenarios":"Constructing xdp.STUNServer on darwin, windows, freebsd, etc. — either directly in cross-platform code or via tests that aren't gated by build tags when run on a non-Linux host.","commonSituations":"Developing on a Mac against Linux production; CI build/test matrices that run the package on all GOOS; referencing derp/xdp without platform guards in shared packages.","solutions":["Gate the code with a //go:build linux constraint or a runtime.GOOS check that falls back to the userspace STUN implementation.","Build and deploy the XDP component only on Linux hosts with a kernel/dependencies that support XDP."],"exampleFix":"// before (fails on darwin/windows: \"unimplemented on this GOOS\")\nsrv, err := xdp.NewSTUNServer(cfg)\n\n// after\n//go:build linux\nsrv, err := xdp.NewSTUNServer(cfg)","handlingStrategy":"validation","validationCode":"if runtime.GOOS != \"linux\" {\n\treturn fmt.Errorf(\"xdp STUN server requires linux; build this binary for linux or use the userspace STUN implementation\")\n}\nsrv, err := xdp.NewSTUNServer(cfg)","typeGuard":"// compile-time guard: only allow compilation of XDP paths on linux\n//go:build linux\n\nfunc newXDPSTUNServer(cfg *xdp.STUNServerConfig) (*xdp.STUNServer, error) {\n\treturn xdp.NewSTUNServer(cfg)\n}","tryCatchPattern":null,"preventionTips":["Put XDP-dependent code behind //go:build linux files with a stub for other platforms.","Provide a runtime.GOOS switch that falls back to the userspace STUN server in shared code.","Tag XDP tests with the linux build tag so cross-platform CI doesn't hit the stub."],"tags":["xdp","ebpf","stun","platform","build-tags","linux"],"backgroundTag":"unsupported-platform","analyzedSha":"6e0912f97994f927632b34ae9e63b53d6516a6ac","analyzedAt":"2026-08-18T08:17:25.280Z","contentChangedAt":"2026-08-18T08:17:25.280Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}