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
+27.7k Golang : How to create new XML file ?
+19.1k Golang : Saving private and public key to files
+3.9k HTTP common errors and their meaning explained
+3.7k Chrome : How to block socketloop.com links in Google SERP?
+27.7k Golang : Get first few and last few characters from string
+15.6k Golang : How to tell if a file is compressed either gzip or zip ?
+6.3k Golang : Getting Echo framework StartAutoTLS to work
+13.8k Golang : How to get Unix file descriptor for console and file
+23.8k Golang : Convert IP address string to long ( unsigned 32-bit integer )
+8.8k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+4.8k Golang : Launching your executable inside a console under Linux