Install Go
The pros and cons of Go language, here is not introduced, the following directly talk about the installation of Go:
Go official website : http://golang.org/(requires FQ software)
Domestic : http://www.golangtc.com/download
Download the
ObjectiveThe process communication methods under Linux are basically inherited from the process communication methods on the UNIX platform. The two main players at T-Lab and BSD (UC Berkeley's Berkeley Software Release Center), which have made
Golang only for No whilePackage Mainimport ("FMT" "OS" "Bufio") func fortest (aint)int{sum:=0 //' I: = 0 ' and start condition. ' i++ ' and incrementing the condition. ' I forI: =0; i {sum+=i}returnsum}//read the contents of the file
I previously know Golang also very superficial time, has been to goroutine thunderclap piercing, I believe many classmates and I, will think in Go code, Goroutine figure everywhere, in fact, is not so.
The two days involved a small project in
Design a stack that supports PUSH,POP,TOP operations and can retrieve the smallest elements within a constant time.
Push (x)-pushes element x into the stack.
Pop ()--Removes the element at the top of the stack.
Top ()--Gets the top
Golang installation GrpcInstall the official installation command:
Go get Google.golang.org/grpc
is not installed, will be reported:
Package google.golang.org/grpc:unrecognized Import Path "Google.golang.org/grpc" (https Fetch:get https:// Google.
In the case of a language, there are two ways in which a function is passed, one is value passing, and the other is a reference pass, so how does the go language pass the parameterValue passing is a copy of the passed variable, reference passing
Let's introduce the type system of the Go language
Type systems in the Golang
Type system refers to the type architecture of a language. A typical type system typically contains the following basic elements:
Basic types, such as Byte, int, bool,
Happens before is a common concept in the memory model, and Go also defines happens before and the various operations that occur happens before relationships, because of these happens before operation Guarantees, We write a multi-goroutine program
Sometimes you may need to convert variables to other types. Golang does not allow arbitrary handling of such conversions, which are certain rules that are guaranteed by the type system's coercion. In this article, we will discuss what conversions
Problem Introduction
JSON serializes a struct if it has a field string or []byte type but actually holds the data in JSON format, such as
type Message struct { From string `json:"from"` To string `json:"to"` Data string
Golang does not have a generic <>, but can receive various types of values through interface{}.
Use slices and generic instances as follows:
Type Slice []interface{}func newslice () Slice { return make (Slice, 0)}func (this* Slice) Add (elem
Although the go compiler produces local executable code, the code is still running on the Go runtime (this part of the code can be found in the runtime package). This runtime is similar to the virtual machine used by the Java and. NET languages, and
Programming always encounter a variety of strange strange pits, the correct mastery of language use posture, can effectively avoid stepping on the pit flashing waist.
Go provides only a loop, a for loop, that can be used in the same way as C,
Download Linuxgo
01 Downloads Linuxgo.png
Go to Folder
02 go to folder. png
Open Terminal
03 Opening Terminal.png
Terminal interface
04terminal interface. png
Unzip the installation Go
05 Decompression and
The types defined in the Golang program have methods associated with them. Let's take a look at an example: "' Gotype T struct {name String}func (T T) printname () {fmt. Println (T.name)}func main () {t: = t{name: "Michał"} T.printname ()} "" As you
4.7.1 Prefixes and suffixesHasprefix determines whether the string s begins with prefix:strings.HasPrefix(s, prefix string) boolHassuffix determines whether the string s ends with suffix:strings.HasSuffix(s, suffix string) bool
package mainimport ("
1. Download Protoc
can go to https://github.com/google/protobuf/releases download the source code to compile their own
or https://github.com/google/protobuf/releases to download a compiled binary file
2. Installing Protoc-gen-go
go get
Go Environment configuration
New Catalog
~/.go_env/go~/.go_env/gopath
Download Go's + + version to "~/.go_env/go"
Add the following code to the. Profile
export GOROOT=$HOME/.go_env/goexport GOPATH=$HOME/.go_env/gopathexport
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.