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.3k Android Studio : Indicate progression with ProgressBar example
+12.1k Golang : Pagination with go-paginator configuration example
+15.1k Golang : Get HTTP protocol version example
+7.3k Golang : Word limiter example
+12.9k Swift : Convert (cast) Int to String ?
+13.8k Golang : Human readable time elapsed format such as 5 days ago
+7k Golang : Gargish-English language translator
+12.4k Golang : Extract part of string with regular expression
+11.5k SSL : The certificate is not trusted because no issuer chain was provided
+10.6k Golang : Flip coin example
+9.1k Golang : Gonum standard normal random numbers example