Merge remote-tracking branch 'upstream/master'

This commit is contained in:
invzhi
2018-01-02 15:00:37 +08:00
4 changed files with 5 additions and 3 deletions

View File

@@ -19,7 +19,7 @@ While this might seem to be a shallow problem, when the codebase grows and more
For other languages there are many variables when it comes to writing code. Every language is good for its use case, but Go is a little special because it was designed at a company which is the very synonym of the Internet (and distributed computing). Typically in order to optimize programs, developers choose to write Java over Python and C++ over Java, but almost all available languages widely in use were written decades ago when 1GB storage was much pricier. Now storage and computing is relatively cheap and computers are getting multiples cores, but the "old languages" are not harnessing concurrency in a way that go does. It's not because those languages are bad; utilizing concurrency wasn't a relevant usecase while the older languages evolved.
To mitigate all the problems that Google faced with current tools, they wrote a systems language called Go which you are about to learn! There are many advantages to using golang and there are disadvantages too, for every coin has both sides. One of the significant improvements in in code formatting. Google has designed the language to avoid debates on code formatting. Go code written by anyone in the world (assuming they know and use `gofmt`) will look exactly the same. This won't seem to matter until you work in a team! Also when the company uses automated code review or some other fancy technique, the formatted code may break in other languages which don't have strict and standard formatting rules, but not in go!
To mitigate all the problems that Google faced with current tools, they wrote a systems language called Go which you are about to learn! There are many advantages to using golang and there are disadvantages too, for every coin has both sides. One of the significant improvements is in code formatting. Google has designed the language to avoid debates on code formatting. Go code written by anyone in the world (assuming they know and use `gofmt`) will look exactly the same. This won't seem to matter until you work in a team! Also when the company uses automated code review or some other fancy technique, the formatted code may break in other languages which don't have strict and standard formatting rules, but not in go!
Go was designed with concurrency in mind, please note that parallelism != concurrency, there is an [amazing post](https://blog.golang.org/concurrency-is-not-parallelism) by Rob Pike on the [golang blog](https://blog.golang.org/), you will find it there, it is worth a read.

View File

@@ -80,6 +80,8 @@ The following example shows how to operate on a database based on the `database/
fmt.Println(department)
fmt.Println(created)
}
rows.Close()
// delete
stmt, err = db.Prepare("delete from userinfo where uid=?")

View File

@@ -38,7 +38,7 @@ Aslında bu çözümünde yeterince basit olmadığını biliyorum. Bakalım dah
Şimdi daha iyi gibi.`:=` kullanarak `var` ve `type` ihmal edilebiliyor, buna öz ifade deniyor. Ama bir dakika, tek bir şart var: bu yöntemi sadece fonksiyon içinde kullanabilirsiniz. Fonksiyon gövdesi dışında kullanırsanız derleme hatası alırsnız. Bundan dolayı, global değişkenler için `var` kullanıyoruz ve kısa tanımalar içinde `var()` anahtar kelimesini.
`_` (boş) özel bir değişken ismi. Verilen her değer yoksayılır. Örneğin, `35`değerini `b`'ye' atıyoruz ve`34` değerini yoksayıyoruz.( ***Bu örnek sadece nasıl çalıştığını gösteriyor. Genelde fonksiyonlardan dönen değerleri yoksaymak iiçin kullanıyoruz*** )
`_` (boş) özel bir değişken ismi. Verilen her değer yoksayılır. Örneğin, `35`değerini `b`'ye' atıyoruz ve`34` değerini yoksayıyoruz.( ***Bu örnek sadece nasıl çalıştığını gösteriyor. Genelde fonksiyonlardan dönen değerleri yoksaymak için kullanıyoruz*** )
_, b := 34, 35

View File

@@ -221,7 +221,7 @@ func init() {
```
>注意一点beego orm针对驼峰命名会自动帮你转化成下划线字段例如你定义了Struct名字为`User`,那么转化成底层实现的时候是`user_info`,字段命名也遵循该规则。
>注意一点beego orm针对驼峰命名会自动帮你转化成下划线字段例如你定义了Struct名字为`UserInfo`,那么转化成底层实现的时候是`user_info`,字段命名也遵循该规则。
## 插入数据
下面的代码演示了如何插入一条记录可以看到我们操作的是struct对象而不是原生的sql语句最后通过调用Insert接口将数据保存到数据库。