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
+20.2k SSL : How to check if current certificate is sha1 or sha2
+3.7k Chrome : How to block socketloop.com links in Google SERP?
+7.1k Golang : Variadic function arguments sanity check example
+6.8k Swift : Convert (cast) String to Double
+18.2k Golang : Example for DSA(Digital Signature Algorithm) package functions
+5.8k Mac/Linux/Windows : Get CPU information from command line
+5.8k Golang : Get expvar(export variables) to work with multiplexer
+44.5k Golang : Encode image to base64 example
+6k Golang : How to iterate a slice without using for loop?
+4.7k Golang : Configure crontab to poll every two minutes 8am to 6pm Monday to Friday
+18.2k Golang : How to Set or Add Header http.ResponseWriter?
+13k Golang : ROT47 (Caesar cipher by 47 characters) example