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.4k Golang : Handling image beyond OpenCV video capture boundary
+5.6k Golang : ROT32768 (rotate by 0x80) UTF-8 strings example
+4.3k Linux/MacOSX : Search and delete files by extension
+5.3k Golang : How to deal with configuration data?
+18.6k Golang : Find IP address from string
+12.3k Golang : Encrypt and decrypt data with x509 crypto
+14.8k Golang : Basic authentication with .htpasswd file
+13.3k Golang : Read from buffered reader until specific number of bytes
+46.3k Golang : Encode image to base64 example
+7k Golang : Takes a plural word and makes it singular
+5.9k Linux/MacOSX : Search for files by filename and extension with find command
+31.4k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions