Skip to content

Instantly share code, notes, and snippets.

@codenathan
Created December 8, 2021 10:31
Show Gist options
  • Save codenathan/8f531b48cb6d1a2bd5d900e2b4345d51 to your computer and use it in GitHub Desktop.
Save codenathan/8f531b48cb6d1a2bd5d900e2b4345d51 to your computer and use it in GitHub Desktop.

How to start a GoLang Project

This will guide you on how setup a go lang project through terminal. with Go you can now start your project inside any folder.

there a several steps you need to do.

Here are the step

Initialise

Go into the root of the project and type in the following ensure you replace the path of github to your project to anything else, it doesn't have to be github you may chose your own path

go mod init "github.com/codenathan/gostart"

create your root project file

Create a main.go file and you can create a simple hello world

package main

import "fmt"

func main() {
	fmt.Println("Hello, World")
}

the above is a simple hello world file in Go

Installing mod packages

If you require some modules then you can install it using the go get command whereby here i am getting the mux pacakge

go get -u github.com/gorilla/mux

Running your files

Finally to run your files in one go.

go run .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment