This is a creation in Article, where the information may have evolved or changed.
Theme:
Today, small try Golang one hours! For the habit of C + +, Python, Lua Grammar of me, the difficulty is not high, very casually wrote a few simple small programs.
But this random also lets you in some places to jam a bit:
1, compile the time, the parameters of the problem;
2, the introduction of the package mechanism;
3, grammatical features above;
First create 3 folders:
1. src
2. Bin
3. Pkg
Make me angry:
1, is the evil import and package play. Maybe it's for the automated build in Build Project! Anyway, in order to debug the import file, I was almost half an hour. And the most hateful thing is 25 minutes before I don't know where it's wrong.
What the? You said I didn't read Golang's article carefully! Well, if you don't look closely, you'll know that the import export method has to be capitalized in the first letter? Package is able to cut a file into multiple files, at compile time Golang can automatically identify this has the point of reference?
Maybe the only thing I can read is that the compiler threw an exception at compile time, smiling:
"Handsome, you introduced the package but didn't use it!" So I throw you an exception you check under .... "
Perhaps you do not know the import ("package") when you need to join the package prefix!
If you do not want to write the prefix, you need to add a very delicate symbol in front of "."
As for the other, I "Ha hehe" not mention ....
Let me surprise:
1, can be compiled, can be explained ; As a pythoner, I had to give this drum a hand! After all, not everyone wants to publish the source code, and not every customer will run the source code and troubleshoot the error.
2, Performance , two days ago a friend tested C and Golang compiled Fibonacci small program. For a special reason, I'm not going to get the picture. Anyway the same code, run up most test the level of the bottom optimization! Don't you?
After the C-O3 optimization, performance is still off the Golang some distance! But this does not reflect what, after all, Golang young.
As for the interpretation of the language compared to the boring, after all, I think Golang's opponent is Java ...
And the various languages have different optimization means, the contrast is too single and boring! After all, writing code is not a burning machine, looking at the overall performance .... JIT or something like that ...!
At last:
Golang is very good, I also very optimistic about him! Although very young, but there are a few good father and a strong backing--google, the future should be a bright ...