As the number of Go implementations continues to increase, the number of cases where the unsafe package is unlikely to work properly also rises. Currently, there is appengine, gopherjs, and possibly wasm where pointer arithmetic is not allowed.
Currently, protobuf and other packages special cases build tags for appengine and js and may need to add others in the near future. It does not scale very well to blacklist specific known Go implementations where unsafe does not work.
My proposal is to document safe as a community agreed upon tag meaning that unsafe should not be used. It is conceivable that this concept be extended to the compiler rejecting programs that use unsafe when the safe tag is set, but I'm currently more interested as a library owner in knowing whether to avoid unsafe in my own packages.
\cc @zombiezen @dneil @neelance @shurcooL
As the number of Go implementations continues to increase, the number of cases where the
unsafepackage is unlikely to work properly also rises. Currently, there isappengine,gopherjs, and possiblywasmwhere pointer arithmetic is not allowed.Currently, protobuf and other packages special cases build tags for
appengineandjsand may need to add others in the near future. It does not scale very well to blacklist specific known Go implementations where unsafe does not work.My proposal is to document
safeas a community agreed upon tag meaning thatunsafeshould not be used. It is conceivable that this concept be extended to the compiler rejecting programs that useunsafewhen thesafetag is set, but I'm currently more interested as a library owner in knowing whether to avoidunsafein my own packages.\cc @zombiezen @dneil @neelance @shurcooL