前言 大家好,我是 LINE Taiwan Developer Relations 團隊的 - Evan Lin。 經過了一年多來的 LINE Developer Relations 的努力,想要在這篇文章裡面稍微整理一下整個團隊做了哪一些的事情,也希望為了「LINE 開發社群計劃」做年度報告。 根據原先 LINE Developer Relations 所寫的介紹文章 (Introducing Developer Relations team) 裡面很清楚地定義了這個團隊的主要目標如下: External Evangelism: 鼓勵開發者使用 LINE 的平台,API與SDK 來開發出具有魅力與有趣的應用服務。 (Encouraging people to make attractive and interesting services using the APIs and the SDK by LINE) Internal Evangelism: 透過一些方式使得工程師們自我成長與磨練自己 (Doing whatever our engineers feel difficult to do themselves in making improvements at work) Technical Branding and Hiring: 讓更多人了解身為 LINER(LINE 員工的自稱) 有許多有趣與令人興奮的事情。 (Letting people know how fun and exciting it is for engineers to work at LINE) 以下的文章將會分成這三個部分來依序說明,也希望能讓更多的開發者跟著我們一起回顧 2019 開發者關係與技術推廣部有哪些有趣的成果。 文章列表: [LINE DevRel] LINE Taiwan Developer Relations 2019 回顧與 2019 開發社群計畫報告 (part 1: External Evangelism) (本篇文章) [LINE DevRel] LINE Taiwan Developer Relations 2019 回顧與 2019 開發社群計畫報告 (part 2: Internal Evangelism) [LINE DevRel] LINE Taiwan Developer Relations 2019 回顧與 2019 開發社群計畫報告 (part 3: **Technical Branding and Hiring) External Evangelism: 鼓勵開發者使用 LINE 的平台,API 與SDK 來開發出具有魅力與有趣的應用服務 首先先介紹的是關於平台推廣的部分,今年的平台推廣主要有兩個重要的管道。一個就是開發者官方社群 OA (@line_tw_dev) 另外一個就是 LINE 開發者小聚。...
前言:
平常在臉書社群或是 Slack channel (https://t.me/golangtw) 都會聽到一些常問的問題,決定把它整理一下,變成這篇文章,也希望讓更多人經過搜尋來了解與得到解答。 由於經常詢問的問題還不少,這算是一個系列的整理,希望能透過整理成文章的方式給予大家比較深入的了解。
第二篇是 Struct Tags ,希望大家在處理 XML 與 JSON 資料上面,能夠更了解。
相關系列文章整理:
Type Assertion
Struct Tags (本篇)
Struct Tags:
請問一下,像這種直接在 struct 成員宣告後面放字串的,是什麼語法啊?
type Person struct {
Name string `form:"name"`
Address string `form:"address"`
}
我在官方文件中找不到
這個叫做 struct tags Go Wiki: Well known struct tags,通常是用在 JSON 資料格式定義的時候。 以下拿一個簡單的範例來舉例:
package main
import "fmt"
type User struct {
Name string `example:"name"`
}
func (u *User) String() string {
return fmt.Sprintf("Hi! My name is %s", u.Name)
}
func main() {
u := &User{
Name: "Sammy",
}
fmt.Println(u)
}
(範例來自:How To Use Struct Tags in Go)
https://golang.org/pkg/reflect/ func (StructTag) 那邊有一些範例。
其實 Golang 本身提供不少種類的 Struct Tags , JSON, XML, bson 都算是比較常見的格式。
https://github.com/golang/go/issues/23637
Reference:
How To Use Struct Tags in Go
Go Wiki: Well known struct tags