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
+9.8k Golang : Read file and convert content to string
+19.8k Golang : Determine if directory is empty with os.File.Readdir() function
+10.9k Golang : How to determine a prime number?
+11.9k Golang : convert(cast) string to integer value
+9.2k Facebook : Getting the friends list with PHP return JSON format
+19.8k Golang : Convert seconds to human readable time format example
+7.8k Golang : Check from web if Go application is running or not
+9k Golang : How to control fmt or log print format?
+14.3k Golang : How to get URL port?
+9.9k Golang : Find and replace data in all files recursively
+29.5k Golang : Get time.Duration in year, month, week or day