Recursion is the process of repeating a project in a similar way. Also applicable in programming languages, if a program allows you to invoke functions called by the same function, the recursive call function is used as follows.
Copy Code code
1.func copy (DST Writer, SRC Reader) (written int64, err error) This function is copied from one file to another file and is copied to the EOF that reads the file, so it does not return IO. EOF error, parameter is write to target and read target,
Go (also known as "Golang") is a programming language originally developed by Google. It has several design principles since its birth: simplicity, security, and speed. The go language release has a variety of debugging, testing, tuning, and code
1, variable declaration and assignment syntax
Variable declarations in the Go language use keyword var, for example
Copy Code code as follows:
var name string//declaration variable
Name = "Tom"//Assign a value to a variable
The new version of Go has better performance, the Ubuntu software library only to turn over the old version, through the source installation go1.2
Specific steps:
1, to the official website download go1.1.2 tarball, I download to the TEM directory
The can compress files and directories.
Package main import ("Archive/zip" "bytes" "FMT" "Io/ioutil" "OS" "Path/filepath") func main () {if err: = Compress (' gopkg ', ' gopkg.zip '); Err!= Nil {fmt. PRINTLN (ERR)}}//parameter frm can be a
It's easy to traverse a folder in Python, and I need that in the go world. Looking for a document, which has this function (specific reference here: http://golang.org/pkg/path/filepath/) ...
OK, no nonsense, I also want to go to bed early, directly
The example in this article describes how the go language joins a custom HTTP header when requesting HTTP. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
Client: = &http. Client{
The example in this article summarizes the common ways to use a timer in the go language. Share to everyone for your reference. The specific analysis is as follows:
The following three sections of code (A,B,C) are performed with the Go language
This article describes the way the go language reads CSV files and outputs them. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
Package Main
Import (
"Encoding/csv"
"FMT"
"
The example in this article describes the Go Language singleton mode (Singleton) usage. Share to everyone for your reference. The specific analysis is as follows:
Single-case mode (Singleton): Represents a class that generates only one object. The
This article illustrates the way to implement file segmentation in Go language. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
Import (
"Bufio"
"Flag"
"FMT"
"IO"
"OS"
)
The example in this article describes the go language defer usage. Share to everyone for your reference. The specific analysis is as follows:
Defer: When you call a function that is defer, you delay execution until the function is returned, and
The example in this article describes the way that the Go language uses map to implement the Stack function. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
Package stack
The example in this article describes how the Go language calculates the number of days in a specified month. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
Package Main
1. Declare an array of var a[2] int or a:=[2]int{1,2}
2. Array indexArrays are indexed to create the following diagram
Let's do one more test.
The 3.go language can automatically compute the length of an array, for example, you know that
The string processing in the go language is not the same as PHP and Java processing, first declaring the string and modifying the string
Copy Code code as follows:
Package Main
Import "FMT"
var name string//declaration of a
This article describes the go language implementation of simple directory replication. Share to everyone for your reference. The implementation methods are as follows:
Create a separate goroutine traversal file, and the main process is responsible
This example describes how the go language intercepts strings by display length. Share to everyone for your reference. The specific analysis is as follows:
Intercept the string according to the display length, before PHP uses the UTF8 code, 10
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