Significance of Go — Part 2 (Play with VS Code and Introducing Go packages and modules)


Setting up VS Code

Package Section in VS Code
Open up the command window and search
Tick the checkbox in the left-hand side of the search bar and click OK
After the installation
package mainfunc main() {
fmt.Println("Hello, playground")
Automatically adds the import statement to your code
go run main.go
Running the saved file

Introducing Go packages and modules

Creating a module

go mod init
Initialized go.mod file
go run
Running the module
package mainimport (
func main() {
fmt.Println("Hello, playground")
greeting := hello()
func hello() string {
return quote.Hello()
module 1.14require v1.5.2
package modelstype Book struct {
Title string
Sold bool
Pages int
Newly created file under models directory
func main() {
b := models.Book{
Title: "Harry Potter",
Sold: true,
Pages: 900,
Modified main function
Run the program
go build
Build and run an executable


Previous Article




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Create EC2 Instance With Terraform.

[Twitch][1/n] Requirements

Sum of Subarray Ranges

Benefits of Custom Software Development for Healthcare Sector | Jellyfish Technologies

Full Information About Repeater — Myrepeater

Cloning of ‘’ website

Reduce XCode Compile and Link time

Flutter 1.22 is now live; here is all you need to know

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Wasura Wattearachchi

Wasura Wattearachchi

More from Medium

PandaDoc API Enhancements: Jan & Feb Edition

Colima — Docker & K8S for local development

Get Started with Tyk API Gateway on Your Local Machine

Push multiple files under a single commit through GitHub API