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
+6.8k Fix sudo yum hang problem with no output or error messages
+16.3k Golang : Check if a string contains multiple sub-strings in []string?
+29.7k Golang : How to declare kilobyte, megabyte, gigabyte, terabyte and so on?
+12.1k Golang : How to check if a string starts or ends with certain characters or words?
+25.1k Golang : Storing cookies in http.CookieJar example
+14.2k Golang : How to convert a number to words
+19.1k Golang : Calculate entire request body length during run time
+32.8k Golang : How to check if a date is within certain range?
+30.7k Golang : Interpolating or substituting variables in string examples
+17.7k Golang : Login and logout a user after password verification and redirect example
+10.5k Golang : Resolve domain name to IP4 and IP6 addresses.