Create and Run a Go Project

In this tutorial, you will learn how to create and run a sample project in Go programming language.

  1. Create a new folder with the name of your choice using a terminal/command prompt:
  2. 
        mkdir project_name
    
  3. Launch Visual Studio Code IDE and add this project folder to the project explorer.
  4. Create a file with .go extension inside your newly created project folder. Example:
  5. If it is your first time creating a Go project on Visual Studio Code, then it will prompt you to install Go extentions like shown in the image below:
  6. Choose Install All.
  7. Now, write the following code in your sample.go project file.
  8. 
        package main
    
        import "fmt"
    
        func main() {
    	    fmt.Println("Hello world")
        }
       
  9. Run your project with following command via Visual Studio Code terminal:
  10. 
        go run sample.go
        

    The above command should print something like below:

    Hello world

Congratulations, you have learned how to create and run a project in Go programming language.