Install Daemonize
Install git environment
Yum Install Git-y
Get Daemonize
git clone git://github.com/bmc/daemonize.git
Install Daemonize
CD Daemonize./configureMake make install
See if Www.111cn.net is installed
Daemonize-v
Performing the Golang daemon through daemonize
You need to package your Golang program for the executable file (go build) and execute it through daemonize to implement the dae
The example in this article describes the use of a For loop statement in the Golang language. Share to everyone for your reference. The specific analysis is as follows:
A For loop is used to traverse an array or a number. There are also byte and rune two ways to iterate through a string with a For loop. The first is byte and the second is rune.
Copy Code code as follows:
Package Main
Import (
"FMT"
)
Func Main () {
S: = "ABC K
When you use Golang for concurrent programming, when you start a new goroutine asynchronously, the main goroutine does not know if the other goroutine is finished, and once the main goroutine exits, all the goroutine exits. Therefore, you need to control the main goroutine exit time, there are the following methods:
(1) time. Sleep ()
More brutal, not reliable, is to let the main goroutine more run for a while, the actual is not sure whether the oth
Recently, when combing the company's services, decided to pull the basic components out of service. Because the company has a variety of language development services, decided to use thrift to resolve cross-language communication.
Start a server
Thrift's support for Golang is good, and the official package provides a server base class and a simple service simple_server.go. You can implement the server to do authentication and other statistical opera
The example in this article describes the two methods of calling RPC Golang. Share to everyone for your reference, specific as follows:
Golang RPC is invoked in two ways, one in the RPC example:
Copy Code code as follows:
Package Main
Import (
"Net/rpc"
"Net/http"
"Log"
"NET"
"Time"
)
Type Args struct {
A, B int
}
Type Arith int
Func (t *arith) Multiply (args *args, reply * ([]string
The example of this article describes the Golang image image processing method. Share to everyone for your reference, specific as follows:
Golang processing picture is quite simple, I was too functional quite simple, not a thumbnail method.
Copy Code code as follows:
Package Main
Import (
"FMT"
"OS"
"Image"
"Image/color"
"Image/draw"
"Image/jpeg"
)
Func Main () {
F1, err: = OS. Open ("
The Golang itself does not provide a driver to connect to MySQL, but it defines a standard interface for Third-party development drivers. Here to connect MySQL can use Third-party libraries, third-party libraries recommend the use of Https://github.com/Go-SQL-Driver/MySQL this driver, update maintenance is better. The following shows the specific use, the complete code example can refer to the last.
Download driver
sudo go get github.com/go-sql-driv
Golang a lot of open source projects, but there are few official editions. Sometimes the choice is weak, choose a good popular components, can go a lot less detours.
Organize some of the most famous and useful open source components (continuous update) 1.web Framework
Beego
Go get Github.com/astaxie/beego
Http://beego.me2. Database
MONGO (most likely to be the official pkg)
Go get gopkg.in/mgo.v2
Http://labix.org/mgo
Mysql
Go get Github.com/go-sql-dri
function Declaration
The function uses the FUNC keyword declaration, except that the type is post-built, and the rest is similar to the rest of the language. In particular, like variable declarations, if the type of a function parameter is the same, you can add the type only at the end.
Func Add (A, b int) int {
return a + b
}
function return value
The Golang function can return multiple values, which are similar to the attributes of the return
follow the code to learn Golang language. Today we are studying the built-in data structure of the Go language: A dictionary (map).
----------------------------------------------------------------------------------------------------------- -----------------------------------------------------------------
dictionary (MAP)
A dictionary (map) is a data structure built into the go language, a set of unordered sets of key-value pairs.
Some places are calle
There are two ways to initialize a struct in **golang: 1. Declare the key of all fields, 2. Neither declares key, but value corresponds to the order one by one defined.
Although mode 1 is cumbersome, anonymous fields may not have to be initialized when there is an anonymous field in the defined struct, and the anonymous field needs to be initialized in mode 2, otherwise the compiler will error (too few values in struct initializer)."Subclass" in
coverage testing in the Golang
Golang provides a number of tool chains that can be used to facilitate unit testing, analyze performance bottlenecks, provide runtime information, and so on, all of which are useful.
Go test This tool people should use more, I used to do mostly for unit testing, go to do unit testing is very convenient, but I ignored the coverage test.
How much code does the unit test cover?
solving the problem of sticky packets in TCP transmission in Golang
Author: Yu DongweiEmail:usher.yue@gmail.com What is a sticky bag.
Recently in writing https://github.com/UsherYue/ActivedRouter (a HTTP/HTTPS reverse proxy service) encountered a sticky packet problem,
If there is a network programming of the small partners should be aware of the sticky packet problem, for example: the client in the kimono
Use JSON-formatted packets for communicatio
Recently, we've been working on Docker and Kubernetes, both in the go language, in order to get a deeper understanding of Docker and kubernetes, and to learn about the go language.In order to learn in detail, a directory is listed here, will be constantly updated
Golang Study notes-Environment Building Guide (this article)
Golang Study notes-ide selection and Installation GuideContinue to update,
1. Download Protobuf compiler Protoc
Address:
HTTPS://github.com/google/protobuf/releases
Window
Download: Protoc-3.3.0-win32.zipUnzip, copy the Protoc.exe under the bin directory to Gopath/bin, Gopath/bin add the environment variable.Of course can be placed in other directories, need to add environment variables, can let the system find Protoc.exeLinux:Download: Protoc-3.3.0-linux-x86_64.zip or Protoc-3.3.0-linux-x86_32.zipUnzip, copy the Protoc under the bin directory to Gopath/bin, Gopath/bin
As a low-level technology, blockchain technology from the initial digital money to smart contracts to the current industry scenarios distributed application implementation, since 2008, 10 years ago, the blockchain from the original theoretical concept to today's actual scenario application landed, although questioned but have been hard to move forward. Especially in the last two years, the re-construction of the existing industry logic in blockchain has made it undisputed the next development of
Tags: turn database query host UID for TCP user return UTF8Just beginning to contact Golang, just write down a few methods, the principle is not very clear, temporarily just can achieve the point, essay points 1. Database connection var {
= ""
= "" = "" = ""}//Return DB connection
func dbopen () (Db_obj *sql. DB, err error) {
db_obj, Err_open: = sql. Open ("MySQL", dbhostuser+ ":" +dbhostpassword+ "@tcp (" +dbhostip+ ":"
This is a creation in
Article, where the information may have evolved or changed.
In the grammar (i), we learn the basic elements of the basic data types, variables, constants, and so on in go, and in this section we will learn how to organize these elements and eventually write code that can be executed.
In this section include:
The Process Control statement in go;
The use of functions in go;
Go special error handling method;
Process Control statements in the
This is a creation in
Article, where the information may have evolved or changed.
Profile
Golang's package management has been without an official unified solution, and therefore has produced many unofficial package management tools. The GB (https://getgb.io/) I used to be able to separate the various Golang projects well, when the GB-created project was not very integrated into the existing gopath. GB is equivalent to the catalog of the project as Go
This is a creation in
Article, where the information may have evolved or changed.
Original link: Http://tabalt.net/blog/gracef ...Golang Support for smooth upgrade (graceful restart) packages are open source to github:https://github.com/tabalt/gracehttp, welcome to use and contribute code.
Some time ago using Golang to make an HTTP interface, because of the characteristics of the compiled language, modified
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.