用车那个司机紧盯什么东西看那么久?他在干嘛
![]() |
?? ?????? ??? ??: ???? ?? ??? ???? ?????. ????? ?????? ????? ??? ?????.
| |
?? ?????? ??? ??: ???? ?? ??? ???? ?????. ????? ?????? ????? ??? ?????. | |
![]() | |
???????? |
????? ?????, concurrent computing, ????? ?????-?????, ????? ?????????, ????? ?????????, ????? ?????????? ![]() |
---|---|
????? ???? |
10 ??????? 2009 ![]() |
????? |
??? ????, ?? ???????, ????? ?????? ![]() |
???? | ???? ???? |
?????? ?? ??? |
APL, C (??? ?????), ???????2, Newsqueak, BCPL, ??????, Smalltalk, ????, ??????-2, ??????, ?????, CSP, ????? ??????, occam, ????? ?? ????? ??? ????? ???? ?????? ![]() |
?????? |
?????? BSD ![]() |
????? | .go |
go.dev | |
![]() ![]() |
Go ??? ??? ????? ?????? ?????? ?????? ?????? ????? ????? ????? ?????? ?????-?????, ???? ???????? ????? ??????, ??? ?? ????? ????? ??? ?? ??? C. ???? ?????? ?? ??? ???? ???? (????? ???? ??? - ??? ??????? ???????? ??? ?????) ???????? ??? ??????? ??????? ??? ????[1]. ?????? ?? ???? ???? ??????? 2007, ???? ?????? ????? ??????? 2009.
???? ?????? ???? ?????? ??? ????? ?-Go ????? Hugo, Datadog, Docker ???????.
?????
[????? ??? ???? | ?????]??? Go ??????? ????? ????? ??????? ?????? ??? ???? ???????? ????? ??????? ??????, ???? ??? ????? ?? ????? ?????? ??????? ????? ????????. ????? ?????? ??? ??:
- ????? ?????: ?????? ????????? ??????? ????? ???????.
- ????? ???? ????????? ??????? ??? ?????? ?????? ????? ??????.
- ????? ??? ???? ??? ???? ??????? ???????.
- ??? ????? ????.
??????
[????? ??? ???? | ?????]????? ???? ????? ?? ?????? ?? ??? C - ????? ???????? ????????, ???? ???? ????? ?????? ?? ??????. ??? ??????? ?????? ???? ???? C ???? ?????? ?? ????? ???????? ????? ?????, ?????? ?????????? ?????? ????? ?????? ???? (????, go ?-select) ????? ?????? ???? C. ?????? ?? ??? ?? ????? ?? ?? ??? ??????? ?? ??? Python[2], ???? ???? ?????? ??? ???? ?????, ?????? ?????-????? (multi-line string), ????? ?? ???? "?????" ?????? ????? ?? ?????? (????: "[2:12]str") ????.
???? ???? ???? ???? C ???????? ??? ??? ?????? ?? ?????? ???????? ?????????. ??????? ???? ???? C:
int a, b;
int foo(int a, int b);
?????? ?????? ???????:
var a, b int
func foo(a, b int) int
????? ?????? ????? ?? ??? ????? (?????? fmt) ??????? ????? ????? ??????? ???? ????? ???????. ??? ???? ????? ??????? ??? ??? ??? ????? ???? ???? ?? ???????? ??????. ??????? ???????? ??????? ???? ?? ????? ?? ???? ?????? ?????? ????? ???? ??? ????? ?????? ?? ????? ??????? (?????? ????? ?? ??????? ???? ????? ?????? ?-C). ????? ?? ?????? ????? ?? ????? ????, ?????? ????? ?? ????, ???? ?? ????? ???? ????.
???? ????? ????????? ???? - ?????, ???? ?????? ???????? ????????, ?????? ???????? ????????? ?????, ????? ???? ?? ??????? ?? ??????. ???????? ???? GO ?? ????.
??? ???? ????? ??????? ????? ??????? ?????? try..catch ????? ????? ++C, ?'???? ?? #C. ????? ??? ???? ?????? ????? ???? ????? ???????? ?????? ?????? ???? "error" ?????? ????? ??????? ??????:
if value, err := someFunction(someVar);err!=nil{
fmt.Println("there was an error calling 'somefunction' : %s ", err.Error())
}
??? ???? ?????? panic ???? ?????? ????, ??? ?????? defer ?????? ???????? ?????? ????? ???? ???? ???????? ???????.
????? ????????
[????? ??? ???? | ?????]??????? ?????? ????:
????? | ????? | ????? | ???? | ????? | ????? ?????? |
---|---|---|---|---|---|
integer | ???? ??? | int8 int16 int32 int64 |
8 ????? 16 ????? 32 ????? 64 ????? |
???? ??? ?????? ????? ?-2 | 24- |
unsigned integer | ???? ???? | uint8 uint16 uint32 uint64 |
8 ????? 16 ????? 32 ????? 64 ????? |
???? ??? ?????? ?????? ??????? | 24 |
float | ???? ???? | float32 float64 |
32 ????? 64 ????? |
????? ??? ?? ?? ???? ?????? | 0.5 |
complex | ???? ????? | complex64 complex128 |
64 ????? 128 ????? |
???? ????? ?????? ????? ??? ?? ?? ???? ??????. ???? ?????? ???? ????? ???? i | 12+5i |
string | ?????? | string | ????? | ?????? ???? ??????? ????? ?????? (?? ????) | "hello" |
????? ????? ?????
[????? ??? ???? | ?????]??? GO ????? ????? ??? ?????? ????? ??????[3] ??? ???? ???????? ????? ???? ++C, #C ?? Java, ????? ????? ????? ??????? ?? ?????, ?? ?????? ??????????, ????? ???????[4] ,?????????? ??????? ???? ?????? ??? ??????? ????? ????? ????? ?????? ????[5], ?? ??????? ???? ???? ????[6].
???????? ??????
[????? ??? ???? | ?????]??????? ????? ????????:
- ????? - ?????, ?????? ?????? ??????? ????? ???? ?????, ???? ????? ????? ?????.
- ?????? ????? - ?????, ????? ?? ????? ????? ?? ?? ???, ?? ???? ?????? ?? ?????? ??????? ????? ???????? =: ????? ????? ??????, ?? ?????? ?? ?? ??????, ?? ?????? ????? ??? ??????.
- ????? - ?????, ?? ???? ????? ?? ????? ???????? ????? ???? ?? ??? ?????? ????? ?? ????? ?????? ????? ????. ???? ?? ???? ?????? ????? ???? ???? ????? ?? ?????? ?? ???????. ??????? ????? ???? ????????? ????? ???? ??????? ???.
?????? ?????? ????
[????? ??? ???? | ?????]??? GO ?????? ?????? ?????? "????" - ?? ?? ?????? ?? ??????, ?????? ???????? ?????? ??? ????? ????, ????? ???? ???? ?? ????? ?? ??????. ?? ??? ???? interface, ???? ???? ????? ?-interface ???? Java, ?? ????? ?????: ??? ?? ???? ?????? ?????? ???? ?????? ???? ?? ?????.
?-GO ??? ????? ?????? ???? (???? ????? 1.01), ???? ????? ?????? interface - ????? ???? ???? ???????? ?? ?????? ??????? ?? ??? ??????? ?? ?????????? ????, ?? ?? ???? ??????? ?????, ???? ???????? Max ?????? ?? ????? ????? ????? ?????. ???? ???? ?????? ???? ?????, ?????? ??????, ???? ?????? ????? ??? ({}interface) ?????? ?????? ?-*void ???? C, ????? ???? (?????? ????? ???????? ???? ????) ??? ????? ?????? ????? ???????. ?? ???, ??? ???? ???? ?????? ???? ??? ?????? ???? ++C ?? Generics ????? #C ??'????, ?? ????? ???????? ???? ?????. ?? ?? ??? ?????[7]: ”????? ?????? ???? ?????? ???? ?????. ????? ?? ??????? ???? ???? ???, ?? ?? ??? ?????? ????? ??????? ??? ???? ??.”
?????? Hello world
[????? ??? ???? | ?????]?????? Hello world, ????? ??? ?????? ?? ???? Hello world:
package main
func main() {
Println("Hello, World")
}
???? ??? ???? ?????? ?????? ????, ????? ?????? echo ???????:
package main
import (
"os"
"flag" // command line option parser
)
var omitNewline = flag.Bool("n", false, "don't print final newline")
const (
Space = " "
Newline = "\n"
)
func main() {
flag.Parse() // Scans the arg list and sets up flags
var s string
for i := 0; i < flag.NArg(); i++ {
if i > 0 {
s += Space
}
s += flag.Arg(i)
}
if !*omitNewline {
s += Newline
}
os.Stdout.WriteString(s)
}
??????? ????????
[????? ??? ???? | ?????]??? ???????? ????? ?? Go (???????)
??? ???????? ????? ?? Go (???????)
Go, ???? ??????? ??? (??????)
Go, ??????? ????? ???????
- ?? ???? ?? ??? Go
- ????? ??????? ????? ????
- ???? ??? ?-Go ?-??????
- ???? ?? ???? ????, ?? ????????? ?????? ??? Go
????? ??????
[????? ??? ???? | ?????]- ^ Go, GitHub (???????)
- ^ Google's Go: A New Programming Language That's Python Meets C++, TechCrunch (???????)
- ^ Frequently Asked Questions (FAQ) - The Go Programming Language, go.dev
- ^ Effective Go - The Go Programming Language, go.dev
- ^ Is Go object oriented?, flaviocopes.com (???????)
- ^ Composition over Inheritance in Go, odetocode.com
- ^ Frequently Asked Questions (FAQ), ???? The Go Programming Language