Project Setup
Prerequisites
- Go version 1.22 or higher
- Terminal for accessing Go via its command line interface (CLI).
- Text Editor with Go syntax support.
- VSCode is recommended, along with the official Go extension.
Project Setup
Create Folder
- Open your file manager.
- Create folder with name that you want (also Go want).
Go's project folder name recommendation:
Initiate Project
Open terminal
Change directory to project folder.
You can use
cd
command to do that.For example:
shcd new_gowok_project
Initiate Go project inside it using this command.
shgo mod init new_gowok_project
Now, you can open this folder using text editor.
Create Go File
- Using your file manager or text editor, create new file with name
main.go
. - Put code below inside that file.
go
package main
func main() {
// your code here
}
Run
To run Go code, use this command:
sh
go run main.go
You can see any output?
No?
Yeah, that's actually run successful.
Congratulations!!!