Hello World Golang Code Example Using Visual Studio Code

Here is a simple Golang code example that you can run using Visual Studio Code:

  1. Open Visual Studio Code and create a new file with the extension “.go”.
  2. Copy and paste the following code into the file:
package main

import "fmt"

func main() {
    fmt.Println("Hello, world!")
  1. Save the file with a meaningful name, such as “hello.go”.
  2. Open the terminal in Visual Studio Code and navigate to the directory where the file is saved.
  3. Run the following command to compile and run the program:
go run hello.go
  1. If everything was set up correctly, you should see the message “Hello, world!” printed in the terminal.
Follow us on social media
Follow Author