Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Goではじめるバックエンド開発
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
ak2ie
June 17, 2023
Technology
79
0
Share
Goではじめるバックエンド開発
2023/06/17「【Developers Guild】バックエンドエンジニア交流会」での発表資料です
ak2ie
June 17, 2023
More Decks by ak2ie
See All by ak2ie
Claude Codeはレガシー移行でどこまで使えるのか?
ak2ie
1
1.5k
SVG完全に理解してグラフ書いてみた
ak2ie
0
57
Go言語CLIツールで生産効率UPした話
ak2ie
0
120
Notion APIと学ぶNext.js
ak2ie
0
580
NestJSのはじめ方
ak2ie
0
160
フロントエンドでDDDやってみた
ak2ie
0
85
初心者がシビックテックに参加してみた
ak2ie
0
120
Firebase についてとことん語りたい
ak2ie
0
130
D3.jsでグラフを描いてみた
ak2ie
0
120
Other Decks in Technology
See All in Technology
エージェント時代の UIとAPI、CLI戦略
coincheck_recruit
0
140
Oracle Exadata Database Service on Cloud@Customer X11M (ExaDB-C@C) サービス概要
oracle4engineer
PRO
2
7.9k
新卒エンジニア研修、ハンズオンの設計における課題と実践知/ #tachikawaany
nishiuma
2
120
コードや知識を組み込む / Incorporate Code and Knowledge
ks91
PRO
0
210
生成AIはソフトウェア開発の革命か、ソフトウェア工学の宿題再提出なのか -ソフトウェア品質特性の追加提案-
kyonmm
PRO
2
840
Modernizing Your HCL Connections Experience: Visual Report to chain, Profile Enhancements, and AI Integration
wannesrams
0
280
20260428_Product Management Summit_Loglass_JoeHirose
loglassjoe
4
7.1k
鹿野さんに聞く!CSSの最新トレンド Ver.2026
tonkotsuboy_com
3
220
AI時代の品質はテストプロセスの作り直し #scrumniigata
kyonmm
PRO
4
1.3k
VespaのParent Childを用いたフィードパフォーマンスの改善
taking
0
260
Google Cloud Next '26 の裏でこっそりリリースされたCloud Number Registry & Cloud Hub コスト分析 を試してみた
hikaru1001
0
160
AgentCore×VPCでの設計パターンn選と勘所
har1101
4
390
Featured
See All Featured
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
55k
The SEO Collaboration Effect
kristinabergwall1
1
440
Docker and Python
trallard
47
3.8k
GraphQLとの向き合い方2022年版
quramy
50
15k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.4k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
820
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
230
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
Navigating Algorithm Shifts & AI Overviews - #SMXNext
aleyda
1
1.2k
Navigating Team Friction
lara
192
16k
Transcript
Goではじめる バックエンド開発 2023/06/17
自己紹介 • 名前:ak2ie • 職業:Webエンジニア • 好きなもの:コーヒー、YouTube
バックエンド どんな言語で開発してますか?
Ruby on Rails?
PHP?
TypeScript?
Go!
目次 • Goとは • Goを使っている企業 • Goの特徴 • HTTPサーバー •
テスト • DB操作
Goとは • Googleが2012年にリリースしたプログラミング言語 • マスコットキャラクターはGopher(ゴーファー) • 半年に1度バージョンアップし、最新バージョンは1.20 • ver.1系は後方互換性があるので、仕事でも安心して使える by
Renée French
Goを使っている企業 • メルカリ ◦ メルカリUSのバックエンドで採用 • ヤフー ◦ 分散オブジェクトストレージをGoで実装 https://findy-code.io/engineer-lab/go-findy-event-1
https://www.slideshare.net/techblogyahoo/go-go-conference-2017-spring
Goの特徴 • 静的型付き言語 • シンプルな構文(ループはfor文のみ) • 標準ライブラリが充実 ◦ HTTPリクエスト処理 ◦
DB操作 ◦ テスト • Goを初めて学ぶ方は「プログラミング言語 Go完全入門」がおすすめ http://tenn.in/go
HTTPサーバー • 標準ライブラリでHTTPリクエスト を処理できる • http://localhost:8080/hello で”hello world!”を返す package main
import ( "net/http" ) type Handler struct{} func Hello(w http.ResponseWriter, r *http.Request) { w.Write([]byte("hello world!")) } func main() { http.HandleFunc("/hello", Hello) http.ListenAndServe(":8080", nil) } 処理 ルーター
テスト • 標準ライブラリでテストを実 行できる • テスト関数 ◦ _test.goで終わる ◦ Testから始まる
◦ *testing.Tが引数 // main_test.go package main import ( "net/http" "net/http/httptest" "testing" ) func TestHello(t *testing.T) { r := httptest.NewRequest(http.MethodGet, "/hello", nil) w := httptest.NewRecorder() Hello(w, r) if w.Body.String() != "hello world!" { t.Errorf("result should be \"hello world!\", but %s", w.Body.String()) } } 検証 処理
DB操作 • 基本的操作は標準ライブラリで実装可能 • エンジンに応じてドライバーを使い分ける ◦ PostgreSQLなら”jackc/pgx”など • DB接続 ◦
db, err := sql.Open(“pgx”, “【接続情報】”) • クエリ実行 ◦ db.Query(“【クエリ】”)
まとめ • GoはGoogleがリリースしたプログラミング言語 • 現在ver.1.20が最新。ver.1系は後方互換性があるので仕事でも使える • 有名企業でも採用事例あり • 構文がシンプル •
標準ライブラリが充実 ◦ HTTPサーバー ◦ DB ◦ テスト