This is a creation in
Article, where the information may have evolved or changed.
Conceptual differences:
1.Go has no inheritance and virtual functions, but provides interface interface.
2.Go has pointers, but no pointer arithmetic.
3.Go provides garbage collection. No Delete required
A 4.Go string resembles a C + + const char*. Cannot be modified.
5.Go Few types are reference passes.
The external visibility of 6.Go is identified by a case-by-letter definition. In C + + is public,private.
7.Go suppresses implicit type conversions.
8.Go does not support function overloading and operator redefinition.
9.Go uses nil to indicate an invalid pointer.
10. Opening curly brace { must be on the current line.
0. Naming conventions and indentation
1. There is no need for a semicolon at the end of the line ;.
2. The foreign variable or function is capitalized in the first letter.
3. Naming specifications I personally refer to the http://studygolang.com/articles/2059
1. Variables
1. Basic type
var a int8 = 3
var a int16 = 3
var a int32 = 3
var a int64 = 3
var a uint8 = 3
var a uint16 = 3
var a uint32 = 3
var a uint64 = 3
var a float32 = 3
var a float64 = 3
var a int64 = 3
var a int8 = 3
var a int16 = 3
var a int32 = 3
var a int64 = 3
var a string = "ASD"
var a byte = ' V '
2. Enumeration
Const
_ = Iota
A //1
b //2
)
3.type
Type str string
2. Control statements
1.If
If Youcode {
}
2.for
For I:=1; i < x; i++{
No front-facing + + is supported
}
3.switch
Switch (a) {
Case 1:
Case 2:
Default
}
There is no need to break and will return directly.
3. Functions
1.
4. Classes (custom structure) and templates
1.
5. Inheritance
1.
6. Classes, functions, variables referencing other files
1.
7. Interface
1.
8. Arrays
1.
9. Exceptions
1.
10. Concurrency (co-process)
1.
Finally attached:
Package Main
Import(
"FMT"
)
FuncMain (){
FMT. Println ("Helloworld!")
}