SlideShare uma empresa Scribd logo
1 de 74
Go 語言簡介
吳柏毅 Bo-Yi Wu
https://blog.wu-boy.com/
Mediatek Engineer
DevOps
Golang, PHP, Node.js ..
Some open source
Gitea
Gin
Drone
appleboy @GitHub
appleboy @twitter
appleboy @slideshare
appleboy46 @facebook
About Me
2
2017
Google Survey Result
https://blog.golang.org/survey2017-results
Go 基本簡介
Go 語言誕生
Go 語言優勢
Go 語言選擇
誰在用 Go 語言
Robert Griesemer, Rob Pike 和 Ken Thompson
Go 語言初期發展
四件事情讓 Go 發展得更好
1. Ian Lance Taylor 加入
2. Russ Cox 在 2008 年加入
實現了 http.HandlerFunc 及 io 接口
3. 安全專家 Adam Langley
golang.org 網站及 build dashboard
4. Docker 及 Kubernets 使用 GO
2013 年及 2014 年
Golang in China
Go 發佈週期 (半年一版)
2013/05 1.1
2013/12 1.2
2014/06 1.3
2014/12 1.4
2015/08 1.5 (Google 規定以後每半年發佈一版)
2016/02 1.6
2016/08 1.7
2017/02 1.8
2017/08 1.9
2018/02 1.10 (最新版)
Go 語言發展歷史(漫畫版)
https://goo.gl/jGcwXK
為什麼設計 Go 語言
根據 Rob Pike 大神描述 …
Google 遇到的問題
大量的 C++ 代码,同時引入 Java 和 Python
成千上萬的工程师 (每個人風格不同)
數百萬的程式碼 (如何減少代碼產量)
分散式編譯系統 (交叉編譯速度 …)
數百萬的伺服器 (部署時間 …)
Go 語言特性
沒有物件導向 (無繼承特性)
強制類型
Function 和 Method
没有錯誤處理
用字首來區別可否存取
不用的 Import 或變數會引起編譯錯誤
完整的標準函式
支援 UTF-8 格式
沒有物件導向 (無繼承特性)
強制類型
Function 和 Method
没有錯誤處理
用字首來區別可否存取
Import 錯誤
Go at Google: Language
Design in the Service of
Software Engineering
https://talks.golang.org/2012/splash.article
Go 優勢
學習曲線
開發及執行效率
由 Google 維護
部署方便
跨平台編譯
內建 Coding Style, Testing 等工具
多核心處理
誰在用 Go 語言
Go 大型專案
https://github.com/golang/go/wiki/Projects
Why Go
https://github.com/golang/go/wiki/whygo
Switched from other languages.
PHP, Python, Node.js, Java, C++
https://github.com/golang/go/wiki/FromXToGo
5 Reasons Why We switched
from Python To Go
https://hackernoon.com/5-reasons-why-we-switched-from-python-to-go-4414d5f42690
中文: https://blog.wu-boy.com/2017/04/5-reasons-why-we-switched-from-python-to-go/
From Python to Go:
migrating our entire API
https://blog.repustate.com/migrating-entire-api-go-python/
Farewell
Node.js
TJ
https://goo.gl/WVxwtb
44
如何將 Go 語言導入團隊
學習曲線
程式碼簡潔
沒有物件導向
團隊開發工具整合
Coding Style
Testing Tool
Benchmark Tool
部署環境 (Go 1.5 Cross Compiler)
降低部署時間
降低測試時間
重啟時間非常快,Load-Balancer 不需要 Pre-warning
系統效能 (記憶體用量, CPU 使用率 …)
EC2 使用量降低 (降低 80 ~ 85%)
Response time 100ms -> 10ms
47
https://talks.golang.org/2014/gocon-tokyo.slide
48
https://talks.golang.org/2014/gocon-tokyo.slide
實際案例
A simple notification service
https://github.com/appleboy/gorush/
A push notification server written in Go
https://github.com/appleboy/gorush/
$ for i in {1..9999999}; do bat -b.N=1000 -b.C=100 POST
localhost:8088/api/push
notifications:=@notification.json; sleep 1; done
從商業利益看 Go 程式語言
https://blog.wu-boy.com/2017/01/business-benefits-of-go/
跨平台編譯
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o hello package
GOOS=linux GOARCH=arm CGO_ENABLED=0 go build -o hello package
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -o hello package
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -o hello.exe
package
Portable
54
https://github.com/mitchellh/gox
Go 核心功能
goroutine 和 channel
Do not communicate by
sharing memory;
instead, share memory by
communicating.
如何設計單一 Queue
解決同時寫入 DB 問題 (Transaction)
MogoDB Transaction
Perform Two Phase Commits.
main func
Handle func
使用 sync.Mutex 解決
Lock and Unlock
效能分析 (使用 Lock)
使用 Channel 解決
goroutine 和 channel
初始化 Channel
效能分析 (使用 Channel)
如何設計多個 Queue
解決單一 Queue 效能問題
多個 Go Application
optimistic concurrency
optimistic concurrency
使用 sync.Mutex 解決問題? (X)
使用 goroutine + Channel 設計單一 Queue? (X)
使用 goroutine + Channel 設計多重 Queue? (X)
Udemy 線上課程
https://www.udemy.com/golang-fight/?couponCode=GOLANG-INTRO
請發問?

Mais conteúdo relacionado

Mais procurados

超簡単!!なTestLinkの使い方
超簡単!!なTestLinkの使い方超簡単!!なTestLinkの使い方
超簡単!!なTestLinkの使い方
Cake YOSHIDA
 
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
Yoshiki Shibukawa
 

Mais procurados (20)

Gstreamer Basics
Gstreamer BasicsGstreamer Basics
Gstreamer Basics
 
ReactとSeleniumの幸せな関係
ReactとSeleniumの幸せな関係ReactとSeleniumの幸せな関係
ReactとSeleniumの幸せな関係
 
Testing in Production, Deploy on Fridays
Testing in Production, Deploy on FridaysTesting in Production, Deploy on Fridays
Testing in Production, Deploy on Fridays
 
FlutterとSupabaseでRDBを使った サーバーレスアプリ開発
FlutterとSupabaseでRDBを使った サーバーレスアプリ開発FlutterとSupabaseでRDBを使った サーバーレスアプリ開発
FlutterとSupabaseでRDBを使った サーバーレスアプリ開発
 
超簡単!!なTestLinkの使い方
超簡単!!なTestLinkの使い方超簡単!!なTestLinkの使い方
超簡単!!なTestLinkの使い方
 
HTTP/2の現状とこれから
HTTP/2の現状とこれからHTTP/2の現状とこれから
HTTP/2の現状とこれから
 
Redmineチケットによるプロジェクト火消し戦略!
Redmineチケットによるプロジェクト火消し戦略!Redmineチケットによるプロジェクト火消し戦略!
Redmineチケットによるプロジェクト火消し戦略!
 
ASP.NETの進化とASP.NET Core Blazorの凄さ
ASP.NETの進化とASP.NET Core Blazorの凄さASP.NETの進化とASP.NET Core Blazorの凄さ
ASP.NETの進化とASP.NET Core Blazorの凄さ
 
varun ppt.ppt
varun ppt.pptvarun ppt.ppt
varun ppt.ppt
 
如何使用 iframe 製作一個易於更新及更安全的前端套件
如何使用 iframe 製作一個易於更新及更安全的前端套件如何使用 iframe 製作一個易於更新及更安全的前端套件
如何使用 iframe 製作一個易於更新及更安全的前端套件
 
Redmineをプラグインで拡張しよう
Redmineをプラグインで拡張しようRedmineをプラグインで拡張しよう
Redmineをプラグインで拡張しよう
 
remote Docker over SSHが熱い
remote Docker over SSHが熱いremote Docker over SSHが熱い
remote Docker over SSHが熱い
 
ユーザ要望に応えるView customize活用事例
ユーザ要望に応えるView customize活用事例ユーザ要望に応えるView customize活用事例
ユーザ要望に応えるView customize活用事例
 
「Redmineの運用パターン集~私に聞くな、チケットシステムに聞け」
「Redmineの運用パターン集~私に聞くな、チケットシステムに聞け」「Redmineの運用パターン集~私に聞くな、チケットシステムに聞け」
「Redmineの運用パターン集~私に聞くな、チケットシステムに聞け」
 
Redmine 5.0 + RedMica 2.1 新機能評価ガイド
Redmine 5.0 + RedMica 2.1 新機能評価ガイドRedmine 5.0 + RedMica 2.1 新機能評価ガイド
Redmine 5.0 + RedMica 2.1 新機能評価ガイド
 
濁点の話
濁点の話濁点の話
濁点の話
 
【BS3】Visual Studio 2022 と .NET 6 での Windows アプリ開発技術の紹介
【BS3】Visual Studio 2022 と .NET 6 での Windows アプリ開発技術の紹介 【BS3】Visual Studio 2022 と .NET 6 での Windows アプリ開発技術の紹介
【BS3】Visual Studio 2022 と .NET 6 での Windows アプリ開発技術の紹介
 
工数把握のすすめ 〜WorkTimeプラグインの使い方〜
工数把握のすすめ 〜WorkTimeプラグインの使い方〜工数把握のすすめ 〜WorkTimeプラグインの使い方〜
工数把握のすすめ 〜WorkTimeプラグインの使い方〜
 
「伝わるチケット」の書き方
「伝わるチケット」の書き方「伝わるチケット」の書き方
「伝わるチケット」の書き方
 
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
ドキュメントを作りたくなってしまう魔法のツール「Sphinx」
 

Semelhante a Go 語言基礎簡介

Using google appengine_1027
Using google appengine_1027Using google appengine_1027
Using google appengine_1027
Wei Sun
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)
Wei Sun
 
Using google appengine_final
Using google appengine_finalUsing google appengine_final
Using google appengine_final
Wei Sun
 

Semelhante a Go 語言基礎簡介 (20)

Introduction to Golang final
Introduction to Golang final Introduction to Golang final
Introduction to Golang final
 
Using google appengine_1027
Using google appengine_1027Using google appengine_1027
Using google appengine_1027
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)
 
用 Drone 打造 輕量級容器持續交付平台
用 Drone 打造輕量級容器持續交付平台用 Drone 打造輕量級容器持續交付平台
用 Drone 打造 輕量級容器持續交付平台
 
JCConf 2015 TW 高效率資料爬蟲組合包
JCConf 2015 TW 高效率資料爬蟲組合包JCConf 2015 TW 高效率資料爬蟲組合包
JCConf 2015 TW 高效率資料爬蟲組合包
 
[Agile Tour Hsinchu 2019] Our practice in the DevOps Process for Manufacture ...
[Agile Tour Hsinchu 2019] Our practice in the DevOps Process for Manufacture ...[Agile Tour Hsinchu 2019] Our practice in the DevOps Process for Manufacture ...
[Agile Tour Hsinchu 2019] Our practice in the DevOps Process for Manufacture ...
 
Ansible & GitLab CI / CD Workshop 101 ( @Agile Tour Taipei 2017)
Ansible & GitLab CI / CD Workshop 101 ( @Agile Tour Taipei 2017)Ansible & GitLab CI / CD Workshop 101 ( @Agile Tour Taipei 2017)
Ansible & GitLab CI / CD Workshop 101 ( @Agile Tour Taipei 2017)
 
Using google appengine_final
Using google appengine_finalUsing google appengine_final
Using google appengine_final
 
Learn Django With ChatGPT
Learn Django With ChatGPTLearn Django With ChatGPT
Learn Django With ChatGPT
 
運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率
 
How to integrate GitLab CICD into B2B service
How to integrate GitLab CICD into B2B serviceHow to integrate GitLab CICD into B2B service
How to integrate GitLab CICD into B2B service
 
Introduction Hugging face.pdf
Introduction Hugging face.pdfIntroduction Hugging face.pdf
Introduction Hugging face.pdf
 
ALPHAhackathon: How to collaborate
ALPHAhackathon: How to collaborateALPHAhackathon: How to collaborate
ALPHAhackathon: How to collaborate
 
Go Lang
Go LangGo Lang
Go Lang
 
Cocoa on Rails 4th
Cocoa on Rails 4thCocoa on Rails 4th
Cocoa on Rails 4th
 
在雲端上啜飲爪哇
在雲端上啜飲爪哇在雲端上啜飲爪哇
在雲端上啜飲爪哇
 
Golang 入門初體驗
Golang 入門初體驗Golang 入門初體驗
Golang 入門初體驗
 
DevOps Days Taipei 2018
DevOps Days Taipei 2018DevOps Days Taipei 2018
DevOps Days Taipei 2018
 
构建网络工具箱
构建网络工具箱构建网络工具箱
构建网络工具箱
 
CICD Workshop 20180922
CICD Workshop 20180922CICD Workshop 20180922
CICD Workshop 20180922
 

Mais de Bo-Yi Wu

Mais de Bo-Yi Wu (20)

Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in Golang
 
Golang Project Layout and Practice
Golang Project Layout and PracticeGolang Project Layout and Practice
Golang Project Layout and Practice
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
Drone 1.0 Feature
Drone 1.0 FeatureDrone 1.0 Feature
Drone 1.0 Feature
 
Drone CI/CD Platform
Drone CI/CD PlatformDrone CI/CD Platform
Drone CI/CD Platform
 
GraphQL IN Golang
GraphQL IN GolangGraphQL IN Golang
GraphQL IN Golang
 
drone continuous Integration
drone continuous Integrationdrone continuous Integration
drone continuous Integration
 
Gorush: A push notification server written in Go
Gorush: A push notification server written in GoGorush: A push notification server written in Go
Gorush: A push notification server written in Go
 
Introduction to Gitea with Drone
Introduction to Gitea with DroneIntroduction to Gitea with Drone
Introduction to Gitea with Drone
 
用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務
 
用 Go 語言打造 DevOps Bot
用 Go 語言打造 DevOps Bot用 Go 語言打造 DevOps Bot
用 Go 語言打造 DevOps Bot
 
A painless self-hosted Git service: Gitea
A painless self-hosted Git service: GiteaA painless self-hosted Git service: Gitea
A painless self-hosted Git service: Gitea
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
用 Docker 改善團隊合作模式
用 Docker 改善團隊合作模式用 Docker 改善團隊合作模式
用 Docker 改善團隊合作模式
 
Git flow 與團隊合作
Git flow 與團隊合作Git flow 與團隊合作
Git flow 與團隊合作
 
PHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding stylePHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding style
 
Docker 基礎介紹與實戰
Docker 基礎介紹與實戰Docker 基礎介紹與實戰
Docker 基礎介紹與實戰
 
Why to choose laravel framework
Why to choose laravel frameworkWhy to choose laravel framework
Why to choose laravel framework
 

Go 語言基礎簡介

Notas do Editor

  1. Robert Griesemer, Rob Pike 和 Ken Thompson。Robert在开发Go之前是Google V8、Chubby和HotSpot JVM的主要贡献者;Rob主要是Unix、UTF-8、plan9的作者;Ken主要是B语言、C语言的作者(共同作者)、Unix之父. Ed 編輯器發明者, vi emcas 的起點。 Brad Fitzpatrick之前是Memcache的作者,目前主要是HTTP2的实现作者。大家可以看到这些作者都是各个领域内的顶尖高手,所以当初我相信一群牛人做出来的Go也一定够牛。
  2. Ian Lance Taylor是GCC的作者之一,目前负责GCC的Go实现;
  3. Russ Cox也是目前Go的领导者之一,他和Rob Pike一起领导Go;
  4. https://medium.com/@tjholowaychuk/farewell-node-js-4ba9e7f3e52b#.ytdscr9d0
  5. 公司內部用 Python, Node.js, PHP
  6. 介紹一下第一屆 gopher conf 6/29 號 星期四
  7. 宣傳月底 golang 講題 gorush