Go build or go install conditional compilation __golang

Source: Internet
Author: User

such as Debug and release version compilation


In the file that you want to use in debug, add:

+build Debug


In another release version of the file, add:

+build!debug


Note//+build xxx This line before and after all need to have a blank line, if placed in the first line as long as there is a blank line behind the line


Compile with:

Go build-tags "Debug" main to compile the debug version, go build main to compile the release version


If a package contains build tag, use: Go install-tags "debug" xxx where xxx is the name of the package

Note: "Debug" can be used in double quotes or ·, which is the 1 on the left of the keyboard on the float, pay attention not to be written in single quotes, that does not


Also, if "debug" does not work, remember to delete the corresponding compiled packages in the PKG directory, most likely compiling system bugs without recompiling

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.