Hacker News new | ask | show | jobs
by bullcitydev 1651 days ago
Author here. I just removed the previous section I had around using build tags because I realized I was using `// +build 1.18` instead of the correct `// +build go1.18`. Oops.
2 comments

Shame build tags aren't part of the language with a proper syntax check instead of magic comments.
Can you show me an example of a language that does syntax checking of build-system related directives at compile time?
C++ #pragma, #include? Golang import statements?

I see why they did this for the Go 1 guarantee, but would prefer if they used a keyword and had a defined restricted syntax for it. There are a growing number of these comments and they’re poorly documented and spread around different tooling. It’s kind of a hack.

https://blog.jbowen.dev/2019/09/the-magic-of-go-comments/

Zig. Rust. The others in this thread.

There are quite a few. Go chose possibly the weakest-safety option of them all.

Nim. C++ attributes (coming soon to C).
FYI: Looks like code blocks are unreadable on mobile (probably a overflow: hidden CSS rule somewhere that truncates lines and doesn’t let you scroll).
Just fixed it. Thanks again!
thanks! I'll check it out!