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
+6.2k Grep : How to grep for strings inside binary data
+32.7k Delete a directory in Go
+7.9k Golang : Routes multiplexer routing example with regular expression control
+11.4k Golang : Convert(cast) float to int
+13.6k Golang : How to check if a file is hidden?
+12.4k Swift : Convert (cast) Int or int32 value to CGFloat
+15.8k Golang : How to check if input from os.Args is integer?
+27.8k Golang : Connect to database (MySQL/MariaDB) server
+23.2k Find and replace a character in a string in Go
+5k Golang : Calculate half life decay example
+29.2k Golang : Login(Authenticate) with Facebook example
+5.9k Linux/Unix : Commands that you need to be careful about