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
+17.6k Golang : Find smallest number in array
+8.5k PHP : How to parse ElasticSearch JSON ?
+5.8k Linux : Disable and enable IPv4 forwarding
+8.2k Golang : Multiplexer with net/http and map
+27.6k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+36.4k Golang : Convert date or time stamp from string to time.Time type
+11.6k Get form post value in Go
+7.8k Golang : Scan files for certain pattern and rename part of the files
+7k Golang : How to setup a disk space used monitoring service with Telegram bot
+16.1k Golang : Get sub string example
+5.5k Golang : Stop goroutine without channel
+37.8k Golang : Comparing date or timestamp