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
+12.2k Golang : convert(cast) string to integer value
+25.8k Golang : How to write CSV data to file
+11.3k Golang : Fix go.exe is not compatible with the version of Windows you're running
+10.2k Golang : Identifying Golang HTTP client request
+17.5k Golang : How to tell if a file is compressed either gzip or zip ?
+13.2k Golang : Convert(cast) uintptr to string example
+12.8k Golang : Sort and reverse sort a slice of bytes
+6.6k Golang : Map within a map example
+11.2k Golang : Read until certain character to break for loop
+13.2k Golang : Handle or parse date string with Z suffix(RFC3339) example
+16k Golang : Read a file line by line
+23.6k Golang : Check if element exist in map