Back to: Golang
Here is a simple Golang code example that you can run using Visual Studio Code:
- Open Visual Studio Code and create a new file with the extension “.go”.
- Copy and paste the following code into the file:
package main
import "fmt"
func main() {
fmt.Println("Hello, world!")
}
- Save the file with a meaningful name, such as “hello.go”.
- Open the terminal in Visual Studio Code and navigate to the directory where the file is saved.
- Run the following command to compile and run the program:
go run hello.go
- If everything was set up correctly, you should see the message “Hello, world!” printed in the terminal.
Follow us on social media
Follow Author