Conditional compilation in Go ?

161 views
Skip to first unread message

alex-coder

unread,
Aug 18, 2024, 3:06:07 PM8/18/24
to golang-nuts
Hi All ! Please advice me : 1. Where to see how Go calls or compiles (detects ) the corresponding runtime (windows, linux etc) in Go code. 2. Where to read about and if there is a conditional compilation in Go. Thanks to everyone

Nagaev Boris

unread,
Aug 18, 2024, 5:41:47 PM8/18/24
to alex-coder, golang-nuts
Hi!

Regarding 2 yes, conditional compilation is done on file level, via
build tags. There are built-in tags for OS and CPU architectures. You
can read here about it:
https://pkg.go.dev/cmd/go#hdr-Build_constraints

Boris

On Sun, Aug 18, 2024 at 4:06 PM alex-coder <a.gus...@gmail.com> wrote:
>
> Hi All ! Please advice me : 1. Where to see how Go calls or compiles (detects ) the corresponding runtime (windows, linux etc) in Go code. 2. Where to read about and if there is a conditional compilation in Go. Thanks to everyone
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a58b3d1d-5d67-476f-b8c9-9456d77dc326n%40googlegroups.com.



--
Best regards,
Boris Nagaev
Reply all
Reply to author
Forward
0 new messages