SlideShare ist ein Scribd-Unternehmen logo
1 von 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
請發問?

Weitere ähnliche Inhalte

Was ist angesagt?

Anatomia do JSF, JavaServer Faces
Anatomia do JSF, JavaServer FacesAnatomia do JSF, JavaServer Faces
Anatomia do JSF, JavaServer FacesRafael Ponte
 
AWS 기반 마이크로 프론트엔드 아키텍처 구축하기
AWS 기반 마이크로 프론트엔드 아키텍처 구축하기AWS 기반 마이크로 프론트엔드 아키텍처 구축하기
AWS 기반 마이크로 프론트엔드 아키텍처 구축하기Eunsu Kim
 
Java Introduction
Java IntroductionJava Introduction
Java Introductionjaveed_mhd
 
Main method in java
Main method in javaMain method in java
Main method in javaHitesh Kumar
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design PrinciplesAndreas Enbohm
 
Arrays in Java | Edureka
Arrays in Java | EdurekaArrays in Java | Edureka
Arrays in Java | EdurekaEdureka!
 
Engage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-RedEngage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-RedPaul Withers
 
Connecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsConnecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsJulien Bataillé
 
炎炎夏日學 Android 課程 - Part1: Kotlin 語法介紹
炎炎夏日學 Android 課程 -  Part1: Kotlin 語法介紹炎炎夏日學 Android 課程 -  Part1: Kotlin 語法介紹
炎炎夏日學 Android 課程 - Part1: Kotlin 語法介紹Johnny Sung
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for javamaheshm1206
 
자바에서 null을 안전하게 다루는 방법
자바에서 null을 안전하게 다루는 방법자바에서 null을 안전하게 다루는 방법
자바에서 null을 안전하게 다루는 방법Sungchul Park
 

Was ist angesagt? (20)

JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
Anatomia do JSF, JavaServer Faces
Anatomia do JSF, JavaServer FacesAnatomia do JSF, JavaServer Faces
Anatomia do JSF, JavaServer Faces
 
AWS 기반 마이크로 프론트엔드 아키텍처 구축하기
AWS 기반 마이크로 프론트엔드 아키텍처 구축하기AWS 기반 마이크로 프론트엔드 아키텍처 구축하기
AWS 기반 마이크로 프론트엔드 아키텍처 구축하기
 
JSON Web Token
JSON Web TokenJSON Web Token
JSON Web Token
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
Main method in java
Main method in javaMain method in java
Main method in java
 
SOLID Design Principles
SOLID Design PrinciplesSOLID Design Principles
SOLID Design Principles
 
Arrays in Java | Edureka
Arrays in Java | EdurekaArrays in Java | Edureka
Arrays in Java | Edureka
 
Spring Batch 2.0
Spring Batch 2.0Spring Batch 2.0
Spring Batch 2.0
 
Engage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-RedEngage 2019: Introduction to Node-Red
Engage 2019: Introduction to Node-Red
 
Rapid json tutorial
Rapid json tutorialRapid json tutorial
Rapid json tutorial
 
Redis Lua Scripts
Redis Lua ScriptsRedis Lua Scripts
Redis Lua Scripts
 
Cheat Sheet java
Cheat Sheet javaCheat Sheet java
Cheat Sheet java
 
Connecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL EndpointsConnecting the Dots: Kong for GraphQL Endpoints
Connecting the Dots: Kong for GraphQL Endpoints
 
炎炎夏日學 Android 課程 - Part1: Kotlin 語法介紹
炎炎夏日學 Android 課程 -  Part1: Kotlin 語法介紹炎炎夏日學 Android 課程 -  Part1: Kotlin 語法介紹
炎炎夏日學 Android 課程 - Part1: Kotlin 語法介紹
 
Introduction to Spring Boot
Introduction to Spring BootIntroduction to Spring Boot
Introduction to Spring Boot
 
Coding standards for java
Coding standards for javaCoding standards for java
Coding standards for java
 
자바에서 null을 안전하게 다루는 방법
자바에서 null을 안전하게 다루는 방법자바에서 null을 안전하게 다루는 방법
자바에서 null을 안전하게 다루는 방법
 
Go lang
Go langGo lang
Go lang
 
Dvm
DvmDvm
Dvm
 

Ähnlich wie Go 語言基礎簡介

Introduction to Golang final
Introduction to Golang final Introduction to Golang final
Introduction to Golang final Paul Chao
 
Using google appengine_1027
Using google appengine_1027Using google appengine_1027
Using google appengine_1027Wei Sun
 
Using google appengine (2)
Using google appengine (2)Using google appengine (2)
Using google appengine (2)Wei Sun
 
用 Drone 打造 輕量級容器持續交付平台
用 Drone 打造輕量級容器持續交付平台用 Drone 打造輕量級容器持續交付平台
用 Drone 打造 輕量級容器持續交付平台Bo-Yi Wu
 
JCConf 2015 TW 高效率資料爬蟲組合包
JCConf 2015 TW 高效率資料爬蟲組合包JCConf 2015 TW 高效率資料爬蟲組合包
JCConf 2015 TW 高效率資料爬蟲組合包書豪 李
 
用 Go 語言 打造微服務架構
用 Go 語言打造微服務架構用 Go 語言打造微服務架構
用 Go 語言 打造微服務架構Bo-Yi Wu
 
[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 ...Edward Kuo
 
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)Chen Cheng-Wei
 
Using google appengine_final
Using google appengine_finalUsing google appengine_final
Using google appengine_finalWei Sun
 
Learn Django With ChatGPT
Learn Django With ChatGPTLearn Django With ChatGPT
Learn Django With ChatGPTKo Ko
 
運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率運用 Docker 整合 Laravel 提升團隊開發效率
運用 Docker 整合 Laravel 提升團隊開發效率Bo-Yi Wu
 
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 serviceAlex Su
 
Introduction Hugging face.pdf
Introduction Hugging face.pdfIntroduction Hugging face.pdf
Introduction Hugging face.pdfKo Ko
 
ALPHAhackathon: How to collaborate
ALPHAhackathon: How to collaborateALPHAhackathon: How to collaborate
ALPHAhackathon: How to collaborateWen-Tien Chang
 
在雲端上啜飲爪哇
在雲端上啜飲爪哇在雲端上啜飲爪哇
在雲端上啜飲爪哇建興 王
 
Golang 入門初體驗
Golang 入門初體驗Golang 入門初體驗
Golang 入門初體驗政斌 楊
 
DevOps Days Taipei 2018
DevOps Days Taipei 2018DevOps Days Taipei 2018
DevOps Days Taipei 2018Cobra Chen
 
构建网络工具箱
构建网络工具箱构建网络工具箱
构建网络工具箱Lv Jian
 

Ähnlich wie 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 高效率資料爬蟲組合包
 
用 Go 語言 打造微服務架構
用 Go 語言打造微服務架構用 Go 語言打造微服務架構
用 Go 語言 打造微服務架構
 
[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
 
构建网络工具箱
构建网络工具箱构建网络工具箱
构建网络工具箱
 

Mehr von Bo-Yi Wu

Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Drone CI/CD 自動化測試及部署
Drone CI/CD 自動化測試及部署Bo-Yi Wu
 
用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構用 Go 語言打造多台機器 Scale 架構
用 Go 語言打造多台機器 Scale 架構Bo-Yi Wu
 
Job Queue in Golang
Job Queue in GolangJob Queue in Golang
Job Queue in GolangBo-Yi Wu
 
Golang Project Layout and Practice
Golang Project Layout and PracticeGolang Project Layout and Practice
Golang Project Layout and PracticeBo-Yi Wu
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub ActionsBo-Yi Wu
 
Drone 1.0 Feature
Drone 1.0 FeatureDrone 1.0 Feature
Drone 1.0 FeatureBo-Yi Wu
 
Drone CI/CD Platform
Drone CI/CD PlatformDrone CI/CD Platform
Drone CI/CD PlatformBo-Yi Wu
 
GraphQL IN Golang
GraphQL IN GolangGraphQL IN Golang
GraphQL IN GolangBo-Yi Wu
 
drone continuous Integration
drone continuous Integrationdrone continuous Integration
drone continuous IntegrationBo-Yi Wu
 
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 GoBo-Yi Wu
 
Introduction to Gitea with Drone
Introduction to Gitea with DroneIntroduction to Gitea with Drone
Introduction to Gitea with DroneBo-Yi Wu
 
用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務用 Go 語言實戰 Push Notification 服務
用 Go 語言實戰 Push Notification 服務Bo-Yi Wu
 
用 Go 語言打造 DevOps Bot
用 Go 語言打造 DevOps Bot用 Go 語言打造 DevOps Bot
用 Go 語言打造 DevOps BotBo-Yi Wu
 
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: GiteaBo-Yi Wu
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golangBo-Yi Wu
 
用 Docker 改善團隊合作模式
用 Docker 改善團隊合作模式用 Docker 改善團隊合作模式
用 Docker 改善團隊合作模式Bo-Yi Wu
 
Git flow 與團隊合作
Git flow 與團隊合作Git flow 與團隊合作
Git flow 與團隊合作Bo-Yi Wu
 
PHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding stylePHP & JavaScript & CSS Coding style
PHP & JavaScript & CSS Coding styleBo-Yi Wu
 
Docker 基礎介紹與實戰
Docker 基礎介紹與實戰Docker 基礎介紹與實戰
Docker 基礎介紹與實戰Bo-Yi Wu
 
Why to choose laravel framework
Why to choose laravel frameworkWhy to choose laravel framework
Why to choose laravel frameworkBo-Yi Wu
 

Mehr von 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 語言基礎簡介

Hinweis der Redaktion

  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