Several reasons for enterprises to surf the internet
-->
Corporate Internet is one of the topics in business circles in recent years, E-commerce, online shopping, online advertising, online supermarkets ..., so many companies are interested in the
This article describes the basic usage of the Go language function. Share to everyone for your reference, specific as follows:
Here's where the go function is different from some other languages.
1 function format is different
Copy Code code
First version of the code, Code is sure there are bugs, first sent to you to test.
@echo off&setlocal enabledelayedexpansion mode con:cols=87 lines=15 title code by FOXJL 2007-12-1 www.jb51.net Color 1a Set long=43,minus=43 set,=^ us, is a
1.func Fields (s string) []string, the function of which is to split the string according to the 1:n space. The last return is[]string slices
Copy Code code as follows:
Import (
"FMT"
"Strings"
)
Func Main () {Fmt. PRINTLN
1.func Contains (S, substr string) bool This function is to find whether a character exists in this string, and exists to return true
Copy Code code as follows:
Import ("FMT""Strings")
Func Main () {Fmt. PRINTLN (Strings.
The interface in the Go language is a collection of a set of methods that are not implemented, and if an object implements all the methods in the interface, then this object implements this interface. Unlike other object-oriented languages, go does
Golang composite types include: structs, arrays, slices, Maps.
1, array
Array
The array in Golang differs greatly from the array in the C language, which is more like an array in Pascal. (Slice, next topic, some like an array in C language)
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
See a lot of Python, and then write a go, you can grab the HD image
Getp.go
Copy Code code as follows:
Package Main
Import (
"Io/ioutil"
"Log"
"Net/http"
"OS"
"RegExp"
"StrConv"
"Strings"
"Sync"
)
var urlist [4]string
Var
The function is very simple, the code is also very concise, here is not much nonsense.
Copy Code code as follows:
Package Main
Import (
"FMT"
"IO"
"Net/http"
"OS"
)
Const (
Upload_path string = "./upload/"
)
Func hellohandle
The example in this article describes the way the go language connects two command-line processes through a pipe. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
Package Main
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{
This example describes the go language exception panic and recovery recover usage. Share to everyone for your reference. The specific analysis is as follows:
Go can throw a panic exception, then catch the exception in defer by recover, and then
The example in this article describes the range usage in the Go language. Share to everyone for your reference. The specific analysis is as follows:
Range is a function defined by the Go language system.
The meaning of a function is to traverse
The example in this article describes how the go language obtains the number of native logical CPUs. Share to everyone for your reference. The specific analysis is as follows:
In general, through the runtime library NUMCPU can obtain the number of
The example in this article describes the Go Language interface usage. Share to everyone for your reference. The specific analysis is as follows:
First, define an interface:
Copy Code code as follows:
Type I interface{
Get () int
put (int)
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
This is a created
article in which the information may have evolved or changed.
package mainimport ("fmt")type TryTarget func()type CatchTarget func()func TryAndCatch(target TryTarget, catch CatchTarget) {defer func() {if err := recover(); err !=
Go from: Use code to describe a WCF configuration fileAt the time of application deployment, the WCF client needs to modify the address URL of the program configuration file because of the change of the server address, the manual modification is
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