Golang : How to force compile or remove object files first before rebuild?
Problem :
You want to use rebuild or refresh your Golang program every time there is a change on any of the source files in your project. Basically, you want to remove the .a
(object) files "first" in the pkg
directory in your workspace each time when there is a rebuild. How to do that ?
Solutions :
In the go build
command, there is a -a
flag that you can use to refresh/rebuild or recompile everything packages that are already up-to-date.
For example :
>go build -a program-name
or you can issue the command
>go clean
first before executing go build
See also : Golang : Build and compile multiple source files
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+8.7k Golang : Executing and evaluating nested loop in html template
+18.1k Golang : Get command line arguments
+19.5k Golang : Get current URL example
+4.6k Mac OSX : Get disk partitions' size, type and name
+7.3k Android Studio : How to detect camera, activate and capture example
+14.7k Golang : Adding XML attributes to xml data or use attribute to differentiate a common tag name
+14.1k Golang : Fix image: unknown format error
+9.4k Golang : Accessing content anonymously with Tor
+15.5k Golang : ROT47 (Caesar cipher by 47 characters) example
+9.1k Golang : How to find out similarity between two strings with Jaro-Winkler Distance?
+26.2k Golang : Calculate future date with time.Add() function
+13.1k Golang : Handle or parse date string with Z suffix(RFC3339) example