A Quick Reference To Running & Building Programs In Go

A Quick Reference To Running & Building Programs In Go

Plus a few tips and tricks!

Plus a few tips and tricks!

 Image for post


is well known for being a comprehensive and yet concise language. Its client interface maintains this paradigm by keeping possible commands simple yet powerful. This article can serve as a reference for common commands with the Go client in order to be a productive Go developer.

Commands in order to be covered:

  • The runbuild, and install commands
  • Including build flags
  • How to build shared libraries
  • Detecting race conditions

Note: You can always use go help to gain further knowledge, although the output can be a bit too verbose at times. This article seeks to fix that!

Let’s get started.

How to use Go run, build & install

Go run is an efficient command in that there are no artifacts needed in order to run your program. Go simply compiles the program into a binary to be ran directly in memory. As long as your Go path and environment variables are defined correctly, you can call go run from anywhere in your system.

While you always need a main package in a Go project, you can execute any file using go run.

Go run examples:

$ go run main.go ## ran from within same file location
Hello World!
$ go run ../some/file/path/hello-world.go ## ran from outside file location
## you can run multiple go files at once
$ go run *.go ## run all go files in current directory
$ go run ../dir/**/*.go ## run all go files in all directories in dir
$ go run first.go second.go third.go $ run go files selectively

If you want to create an executable, you can use the go build command.

tutorial golang

What is Geek Coin

What is GeekCash, Geek Token

Best Visual Studio Code Themes of 2021

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Data Visualization in R with ggplot2: A Beginner Tutorial

Data Visualization in R with ggplot2: A Beginner Tutorial. Learn to visualize your data using R and ggplot2 in this beginner-friendly tutorial that walks you through building a chart for data analysis.

Tutorial: Getting Started with R and RStudio

Get your R programming journey off on the right foot with this RStudio tutorial that walks through everything from installation to best practices.

Tutorial: Loading and Cleaning Data with R and the tidyverse

Learn how to load a data set and clean it using R programming and tidyverse tools in this free beginner-level data analysis tutorial.

R Tutorial: Better Blog Post Analysis with googleAnalyticsR

Learn to compare blog posts on even footing using R programming and the googleAnalyticsR package for blog data analysis in this free tutorial.

Hire Dedicated Golang Developers | Golang Web Development Company

Hire dedicated GoLang developers from WebClues Infotech to build applications using Go language. Get best GoLang developers for your web development projects.