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
ak2ie
June 17, 2023
Technology
0
70
Goではじめるバックエンド開発
2023/06/17「【Developers Guild】バックエンドエンジニア交流会」での発表資料です
ak2ie
June 17, 2023
Tweet
Share
More Decks by ak2ie
See All by ak2ie
SVG完全に理解してグラフ書いてみた
ak2ie
0
47
Go言語CLIツールで生産効率UPした話
ak2ie
0
110
Notion APIと学ぶNext.js
ak2ie
0
570
NestJSのはじめ方
ak2ie
0
140
フロントエンドでDDDやってみた
ak2ie
0
78
初心者がシビックテックに参加してみた
ak2ie
0
110
Firebase についてとことん語りたい
ak2ie
0
110
D3.jsでグラフを描いてみた
ak2ie
0
110
Flutterはじめます
ak2ie
0
150
Other Decks in Technology
See All in Technology
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
17k
Tebiki Engineering Team Deck
tebiki
0
24k
顧客との商談議事録をみんなで読んで顧客解像度を上げよう
shibayu36
0
260
Bill One急成長の舞台裏 開発組織が直面した失敗と教訓
sansantech
PRO
2
380
Agile Leadership Summit Keynote 2026
m_seki
1
640
【Ubie】AIを活用した広告アセット「爆速」生成事例 | AI_Ops_Community_Vol.2
yoshiki_0316
1
110
【Oracle Cloud ウェビナー】[Oracle AI Database + AWS] Oracle Database@AWSで広がるクラウドの新たな選択肢とAI時代のデータ戦略
oracle4engineer
PRO
2
170
ClickHouseはどのように大規模データを活用したAIエージェントを全社展開しているのか
mikimatsumoto
0
260
Greatest Disaster Hits in Web Performance
guaca
0
270
顧客の言葉を、そのまま信じない勇気
yamatai1212
1
360
AIと新時代を切り拓く。これからのSREとメルカリIBISの挑戦
0gm
1
2.7k
20260204_Midosuji_Tech
takuyay0ne
1
160
Featured
See All Featured
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
320
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
WCS-LA-2024
lcolladotor
0
450
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
62
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
1
55
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
730
Abbi's Birthday
coloredviolet
1
4.8k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
57
50k
RailsConf 2023
tenderlove
30
1.3k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
71k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
160
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 ◦ テスト