Golang Introduction and the second step of the pit series

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Golang Introduction and one of the series of stepping pits

Compiling articles

All along, I think Golang is very likes.

It avoids the gofmt of Java/C + + braces in the end of a row or another line of the dead argument, frankly provide a quiet, let everyone shut up quietly write code.

It eliminates the possibility of binary publishing, and all of your vendor must have source code and then compile together. Even the default support for a tool called go get, the goods directly with github,bitbucket such as repo hoster communication, the code from the Internet to take down.

Are we all happy?

Happy! Because everyone's code GOFMT after the same length, easier to read.

Happy! Because all references are source code, we can read, can be developed two times.


But I, not happy! (Which garlic do you count?) Hell, you're going to die! )

I'm really not happy.

Write a thousands of line of code, the compilation speed can endure. When your code comes to a certain amount of code, you're not too happy. Compilation is the turtle speed Ah!

$ time go buildgo build  3.46s user 0.64s system 122% cpu 3.334 total

You can imagine in vim to execute a:! Gobuild the entire editor stuck 3 seconds of embarrassment?

Those pains! Those struggles!

After a bitter lesson, I finally got this thing:

$ alias | grep build gobuild='go install'

The result is:

$ time gobuildgo install  0.62s user 0.25s system 128% cpu 0.675 total

Is it magical?

In fact, the first go install is very slow, but the second time is incremental build, time consumption is basically linking, so it becomes easier to endure some.

Don't get excited, do you have any side effects?

$ gobuildgo install: no install location for directory /Users/zhchang/work/shit outside GOPATH        For more details see: 'go help gopath'

The side effect is that the trick can only be used in Gopath.

Two side effects, go build will generate a build out of the current directory Binary,go install will throw binary into the $GOPATH/bin/below

To sum up, if you are the same as me, a man of the wind, completely unable to tolerate the IDE can't keep up with the pain of the finger, completely unbearable vim by go build slow, please try go install.

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.