How can you build a Go program for a different operating system or architecture using the go build command?
- Use the -o flag followed by the desired OS and architecture.
- Use the -os and -arch flags with the appropriate values.
- Specify the target OS and architecture in the source code.
- Use the -build flag followed by the target OS and architecture.
You can build a Go program for a different operating system or architecture using the go build command by using the -o flag followed by the desired OS and architecture. For example, to build for Linux on an AMD64 architecture, you would use go build -o myprogram-linux-amd64. The -o flag allows you to specify the output binary's name and location with the target OS and architecture in the filename.
Loading...
Related Quiz
- How can you check for a specific error in Go?
- In Go, the _____ statement can be used to execute code based on certain conditions.
- The Marshal and Unmarshal functions in Go are part of the _____ package.
- You have a Go application that is experiencing memory leaks. How would you go about diagnosing and fixing the issue?
- The _____ command is used to tidy the go.mod file by removing any no longer needed dependencies.