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

Quarkus command mode feature

Taraxa Tech UPD — Week 41

How to run Grafana in Dev Env

Event Sourcing: The best way for StashAway?

Jade Explorer, A Minimal Block Explorer for the Ethereum Stack

It’s 5AM… Do You Know Where Your DNS Tools Are? | Itential Developers

Practical use of Design Patterns in Java

Clean code : Error Handling

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

Building with the GitHub API

A figurine of Mona, GitHub’s mascot, on a desk.

GitHub: An open source app for pull request review

Accessing environment variables from kubernetes/helm in NextJs app on the client side

Configure GRPC in macOS