Used to develop with python, accustomed to the virtualenv, now see go, think is not also have similar dongdong, search a bit, sure enough, there. This is the GVM to be said today. Install GVM
$ bash
When the installation is complete, the. GVM
The regular can efficiently extract the contents of a fixed pattern, for example from a URLHttp://blog.jiguba.cn/2018/01 ...
Regular templates
template=^http://blog.jiguba.cn/([\d]{4})/([\d]{2})/([\d]{2})/([w-]+).html$
Implementation code
If you're using a programming language like C # or Java to go, the first thing you'll find is that there's no traditional collection type like ' List ' and ' Dictionary '. It's been confusing me for months. I found a package called ' container/list '
Wrote a simple Golang to generate random strings, share them, and generate uppercase letters.
func init() { r = rand.New(rand.NewSource(time.Now().Unix()))}func RandString(len int) string { bytes := make([]byte, len) for i := 0; i
Test
Rely on management this way
The first choice is to use Govendor as the project's dependency management. The reason is that compared to several of Godoc's recommended dependency management tools, Govendor is the cleanest and only one vendor folder in
Recently in an online platform, architecture ideas are as follows
Architecture Evolution: 1, MVC 2, service split 3, microservices architecture 4, Domain driven design
1. MVC
This stage is mainly the rapid implementation of the product, did not
Disrupts an array of elements that do not have duplicates.Image.png
Golang Code:
package shuffleimport ( "math/rand" "time")type Solution struct { array []int backup []int //备份}func Constructor(nums []int) Solution { return Solution{
A simple introduction: Go is a new language, a concurrent, garbage-collected, fast-compiling language. It has the following characteristics:It can compile a large go program in a few seconds on a single computer. Go provides a model for software
Default installation
Download the installation package https://golang.org/dl/on the website.
Unzip tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz the path after decompression /usr/local/go . which represents $VERSION a Golang version, such
This paper is mainly for the study of "Go Language standard library" Https://books.studygolang.com/The-Golang-Standard-Library-by-Example notes
IO operations in the Go language are encapsulated in the following 4 packages:
1) IO: Provides a basic
golang data structures, used very little in practice, only to do research here.
Package Mainimport ("Container/list" "Github.com/sanity-io/litter") type Thing struct {Id intinfo string}//Golang doubly linked list structure Func Main () {doublelist:
Error handling
The previous share added two functions, one is the editing function, one saves the function
There are a few places in our program that actually ignore the wrong deal.This is not a good practice, especially because of the unexpected
Watching the go language for two days, it is time to practice practiced hand.Go's routine (routines) and Chan (channels) are simply artifacts, and it's not easy to achieve multithreading (multiple routines in go).
So the code is a fool version of
1. Download
Domestic image Download AddressHttps://golangtc.com/download
DownloadGO1.9.2.DARWIN-AMD64.PKG Installation
Enter go in the terminal, if it appears, the installation is successful. Installation Successful
2. Configuration
Obtaining third-party packages with commands
go get -u -v github.com/speps/go-hashids
The code is as follows:
package hashidsimport ( "github.com/speps/go-hashids")//salt 盐值const salt = "salt"//Encode 混淆func Encode(data int) string { hd :=
Gofasion is a lightweight parsing library that facilitates the parsing of interface JSON data in the development process, and its greatest feature is the support of chained calls, which means that the target key name and key value can be obtained
Jumping around in Golang's code ....
Godef Installation
Jump is implemented through GODEF, Godef installation directory is generally $gobin, as long as the Godef command in $path canGodef Command Installation:
go get -v
Preparation knowledge: MySQL transaction
1 Basic operations
Sql. Tx
TX takes an idle connection from the connection pool until the call to commit or rollback is released
tx, err := db.Begin() // 创建tx对象tx.Query(command1)tx.Exec(command2)tx.Commit()
2
Add Edit and save features
Continue to the previous article "Go Basic Learning Record-write Web application-add Edit and save function (i)"
If you build and run the logic of the previous article, trying to access a nonexistent wiki, such
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.