Write some code
- Open a command prompt and cd to your home directory. ...
- Create a hello directory for your first Go source code. ...
- Enable dependency tracking for your code. ...
- In your text editor, create a file hello.go in which to write your code.
- Paste the following code into your hello.go file and save the file.
How do I run a .go file?
A typical Go program is a plain text file with .go file extension. You can run this program using go run hello.go command where hello.go is a Go program file in the current directory.
How do I start coding in go?
The process we use to write software using Go (and most programming languages) is fairly straightforward:
- Gather requirements.
- Find a solution.
- Write source code to implement the solution.
- Compile the source code into an executable.
- Run and test the program to make sure it works.