From d479d6e7faeb61e76f353a9dd6b79c42d5d51f16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Papp?= Date: Tue, 18 Aug 2026 12:27:20 +0200 Subject: [PATCH] Document the nil-safety contract of netstate.State --- client/netstate/netstate.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client/netstate/netstate.go b/client/netstate/netstate.go index f67f863ef..0d7a1268b 100644 --- a/client/netstate/netstate.go +++ b/client/netstate/netstate.go @@ -28,7 +28,9 @@ type State struct { changed chan struct{} } -// New creates a State that starts online. +// New creates a State that starts online. Platforms without network tracking +// pass a nil *State instead: the read methods treat nil as always online and +// never block, so consumers need no nil guards. func New() *State { return &State{ online: true, @@ -37,7 +39,8 @@ func New() *State { } // Set records whether the OS reports any usable network. Transitions wake up -// all Wait callers immediately. +// all Wait callers immediately. Unlike the read methods, Set is not nil-safe: +// it is only for the platform owner that created the State with New. func (s *State) Set(online bool) { s.mu.Lock() defer s.mu.Unlock()