SlideShare a Scribd company logo
1 of 45
Download to read offline
The Go gopher was designed by Renée French.
The gopher stickers was made by Takuya Ueda.
Licensed under the Creative Commons 3.0 Attributions license.
Static Analysis in Go
@GolangUK Conference
18th Aug. 2017
1
Who am I?
Takuya Ueda
@tenntenn
➔ Work for
➔ Communities
&
Go Beginners
in Tokyo
Go Conference
in Tokyo
2
Mercari Europe
3
https://www.mercari.com/uk/
Who am I?
Takuya Ueda
@tenntenn
➔ Work for
➔ Communities
&
Go Beginners
in Tokyo
Go Conference
in Tokyo
4
Agenda
➔ Where’s Gopher?
➔ Static Analysis
➔ Static Analysis in Go
➔ Static Analysis for Products
5
Where’s Gopher?
Find Me!!
Powered by https://gopherize.me
6
Where’s Gopher?
Find Me!!
Powered by https://gopherize.me
7
Where’s “Gopher”?
type Gopher struct { Gopher string `json:"gopher"` }
func main() {
const gopher = "GOPHER"
gogopher := GOPHER()
gogopher.Gopher = gopher
fmt.Println(gogopher)
}
func GOPHER() (gopher *Gopher) {
gopher = &Gopher{ Gopher: "gopher" }
return
}
8
We love grep
$ grep Gopher main.go
type Gopher struct { Gopher string `json:"gopher"` }
gogopher.Gopher = gopher
func GOPHER() (gopher *Gopher) {
gopher = &Gopher{ Gopher: "gopher" }
We can search “Gopher” with grep.
9
Where’s “Gopher” TYPE?
type Gopher struct { Gopher string `json:"gopher"` }
func main() {
const gopher = "GOPHER"
gogopher := GOPHER()
gogopher.Gopher = gopher
fmt.Println(gogopher)
}
func GOPHER() (gopher *Gopher) {
gopher = &Gopher{ Gopher: "gopher" }
return
}
10
How to search “Gopher” type
➔ grep can search only by text
➔ The text must be understood as Go source
code
➔ We need “Static Analysis”
11
Static Analysis
12
Static Analysis & Dynamic Analysis
➔ Static Analysis
◆ Analyzing a program WITHOUT execution
◆ Analyzing structure of a program from source codes
◆ e.g. linter, code complement, code formatter
➔ Dynamic Analysis
◆ Analyzing a program WITH execution
◆ Investigating variables and result of functions
◆ e.g. race detector
13
Reflection
➔ Reflection
◆ Analyzing values and types at runtime.
➔ Reflection in Go
◆ reflect package
◆ It is only way to get struct tags at runtime
◆ encoding package uses reflection to
encode/decode JSONs, XMLs and so on.
14
Static Analysis Tools for Go
➔ There are many static analysis tools for Go
gofmt/goimports code formatter
go vet/golint code checker, linter
guru code comprehension tool
gocode code complement tool
errcheck error handlings checker
gorename/gomvpkg refactoring tools
15
Go for Static Analysis
➔ Go is easy to static analyze
◆ Static typing
◆ Simple syntax
◆ Type inference
◆ No Implicit type conversion
◆ go package is provided as a standard package
Static Analysis gives
a lot of information
16
Sub packages of go package
ast Package ast declares the types used to represent syntax trees for Go packages.
build Package build gathers information about Go packages.
constant Package constant implements Values representing untyped Go constants and their corresponding operations.
doc Package doc extracts source code documentation from a Go AST.
format Package format implements standard formatting of Go source.
importer Package importer provides access to export data importers.
parser Package parser implements a parser for Go source files.
printer Package printer implements printing of AST nodes.
scanner Package scanner implements a scanner for Go source text.
token
Package token defines constants representing the lexical tokens of the Go programming language and basic
operations on tokens (printing, predicates).
types Package types declares the data types and implements the algorithms for type-checking of Go packages.
17
Static Analysis in Go
18
Flow of Static Analysis
Source Code
Token
Abstract Syntax Tree
(AST)
Type Info
Parse
Tokenize
Type Check
go/scanner
go/token
go/parser
go/ast
go/types
go/constant
19
Tokenization - go/scanner,go/token
IDENT ADD INT
Tokens
Source Code: v + 1
➔ Dividing input string into tokens
20
Parsing - go/parser,go/ast
➔ Converting tokens to abstract syntax tree
v + 1
IDENT ADD INT
Source Code:
+
v 1
BinaryExpr
Ident BasicLit
Tokens:
Abstract Syntax Tree:
(AST)
21
AST of “Hello, World”
package main
import "fmt"
func main() {
fmt.Println("Hello, 世界")
}
Run on Playground
*ast.File
[]ast.Decl
*ast.GenDecl *ast.FuncDecl
22
Type Check - go/types,go/constant
➔ Extract type infomation from AST
◆ Identifier Resolution
◆ Type Detection
◆ Constant Evalution
n := 100 + 200
m := n + 300
Constant Evalution
= 300
Type Detection
-> int
Identifier Resolution
23
Getting AST from source code
➔ Use parser.Parse* function
◆ ParseExpr,ParseExprFrom
● Parsing expression
● ParseExpr is simple version of ParseExprFrom
◆ ParseFile
● Parsing a file
◆ ParseDir
● Parsing files in a directory
● Calling ParseFile in the function
24
Getting AST from an expression
expr, err := parser.ParseExpr(`v + 1`)
if err != nil {
/* handling the error */
}
/* use expr */
➔ Parsing an expression
25
Getting AST from a file
const src = `
package main
var v = 100
func main() {
fmt.Println(v+1)
}`
fs := token.NewFileSet()
f, err := parser.ParseFile(fs, "my.go", src, 0)
if err != nil {
/* handling the error */
}
/* use f */
file name which is opened when
src is nil
Source Code
Parsing Mode
26
token.FileSet
➔ Recording positions on files
◆ The position (token.Pos) is represented by integer
◆ The value is unique among multiple files
◆ token.FileSet holds offset of each files
◆ The offsets are recorded at parsing
◆ token.FileSet is passed to parsing function as
an output parameter
type Pos int
27
Demo 1: Parse and Dump an AST
28
https://youtu.be/lM1Pj6xYxZs
Traversing AST - ast.Inspect
➔ Using ast.Inspect
expr, _ := parser.ParseExpr(`v + 1`)
ast.Inspect(expr, func(n ast.Node) bool {
if n != nil { fmt.Printf("%Tn", n) }
return true
})
Traverse the AST
*ast.BinaryExpr
*ast.Ident
*ast.BasicLit
Run on Playground
ast.Walk is more powerful and complex
+
v 1
BinaryExpr
Ident BasicLit
29
Traversing AST - Recursively
func traverse(n ast.Node) {
switch n := n.(type) {
case *ast.Ident:
fmt.Println(n.Name)
case *ast.BinaryExpr:
traverse(n.X)
traverse(n.Y)
case *ast.UnaryExpr:
traverse(n.X)
default:
fmt.Println(n)
}
}
print idetifyer’s name
traverse each terms recursively
switching by types
Run on Playground
traverse a term recursively
30
Demo 2: Inspect identifiers
31
https://youtu.be/mpUgaaASvHo
Type Checking
/* initialize configs for type checking */
cfg := &types.Config{Importer: importer.Default()}
info := &types.Info{
/* TODO: initialize maps which will hold results */
}
pkg,err := cfg.Check("main", fs, []*ast.File{f}, info)
if err != nil {
/* handling the error */
}
/* TODO: use pkg or info */
➔ (*types.Config).Check do a type checking
32
types.Info holds results of type checking
type Info struct {
// Types maps expressions to their types, and for constant
// expressions, also their values.
Types map[ast.Expr]TypeAndValue
// Defs maps identifiers to the objects they define.
Defs map[*ast.Ident]Object
// Uses maps identifiers to the objects they denote.
Uses map[*ast.Ident]Object
// Implicits maps nodes to their implicitly declared objects, if any.
Implicits map[ast.Node]Object
// Selections maps selector expressions (excluding qualified identifiers)
// to their corresponding selections.
Selections map[*ast.SelectorExpr]*Selection
// Scopes maps ast.Nodes to the scopes they define.
Scopes map[ast.Node]*Scope
// InitOrder is the list of package-level initializers in the order in which
// they must be executed.
InitOrder []*Initializer
}
33
Demo 3: Inspect Gopher type
34
https://youtu.be/AuSDtmiMaXI
Static Analysis for Products
Case 1: gpath,go-httpdoc
35
go.mercari.io/go-httpdoc
➔ Generate API Docs from tests of handlers
◆ Just write tests of HTTP handlers
◆ gRPC and JSON RPC are supported
36
Tests for requests and responses
➔ Requests (Responses) can be test by
specifying fields and expected values,
document for each fields
validator.RequestBody(t, []httpdoc.TestCase{
{"Name", "tenntenn", "User Name"},
{"Attribute.Email", "tenntenn@example.com", "e-mail address"},
}, &createUserRequest{})
37
github.com/tenntenn/gpath
➔ Simplefy reflection of struct fields
◆ Reflecting by expression of selectors
◆ Easy to reflect complex struct value
◆ Supports maps and slices (but restricted)
type Bar struct { N []int }
type Foo struct { Bar *Bar }
f := &Foo{ Bar: &Bar{ N: []int{100} }}
v, _ := At(f, `Bar.N[0]`)
fmt.Println(v)
$ go run main.go
100
38
Create own static analysis tools
➔ Reduce costs of code reviews by own tools
◆ Custimized linter for your project
◆ Detecting typical bugs with own tools
◆ You should pay your time for more important things
● algorithm, design, performance and so on
39
Static Analysis in Production
Case 2: Banner Tool
40
Banner Tool
➔ A management tool of in-app banners
In-App Banner
A screenshot of our app (Mercari Atte)
41
Banner Tool
➔ A management tool of in-app banners
Banner Tool
● Delivery Conditions
● Response
Getting Banners
w/ OS, API Version
List of Delivered Banners
w/ Image URL, Destination URL, etc...
Apps
42
Evaluation of Delivery Conditions
Getting Banners
GET /banner/?os=1
String(os) == "1"
Banner Image, etc...
Delivery Condition:
Banner Tool
"1" == "1"
true
BIND
EVAL
➔ Describing delivery conditions by a Go like expression
◆ Eval expressions with go package
◆ Using a function calling for describing a variable with a type
43
Conclutions
➔ Static Analysis is EASY in Go
◆ static typing, simple syntax, go package, etc...
➔ go package can
◆ tokenize, parse and type check
➔ Static analysis in production
◆ own static analysis tools (e.g. gpath, go-httpdoc)
◆ web apps (e.g. Banner Tool)
44
Thank you!
twitter: @tenntenn
Qiita: tenntenn
connpass: tenntenn
45

More Related Content

What's hot

고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들
고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들
고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들Chris Ohk
 
게임엔진과 공간정보 3D 콘텐츠 융합 : Cesium for Unreal
게임엔진과 공간정보 3D 콘텐츠 융합 : Cesium for Unreal게임엔진과 공간정보 3D 콘텐츠 융합 : Cesium for Unreal
게임엔진과 공간정보 3D 콘텐츠 융합 : Cesium for UnrealKyu-sung Choi
 
はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化
はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化
はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化Lintaro Ina
 
Goroutineと channelから はじめるgo言語
Goroutineと channelから はじめるgo言語Goroutineと channelから はじめるgo言語
Goroutineと channelから はじめるgo言語Takuya Ueda
 
ここがつらいよ、Hyperledger Fabricの商用適用(Blockchain GIG #4発表資料)
ここがつらいよ、Hyperledger Fabricの商用適用(Blockchain GIG #4発表資料) ここがつらいよ、Hyperledger Fabricの商用適用(Blockchain GIG #4発表資料)
ここがつらいよ、Hyperledger Fabricの商用適用(Blockchain GIG #4発表資料) NTT DATA Technology & Innovation
 
Dokkuの活用と内部構造
Dokkuの活用と内部構造Dokkuの活用と内部構造
Dokkuの活用と内部構造修平 富田
 
20180711 Metamask
20180711 Metamask 20180711 Metamask
20180711 Metamask Hu Kenneth
 
3週連続DDDその2 深いモデルの探求(ドメイン駆動設計 第3部)
3週連続DDDその2  深いモデルの探求(ドメイン駆動設計 第3部)3週連続DDDその2  深いモデルの探求(ドメイン駆動設計 第3部)
3週連続DDDその2 深いモデルの探求(ドメイン駆動設計 第3部)増田 亨
 
ブロックチェーン統合ツールCactusとトークンエコノミー実現への期待
ブロックチェーン統合ツールCactusとトークンエコノミー実現への期待ブロックチェーン統合ツールCactusとトークンエコノミー実現への期待
ブロックチェーン統合ツールCactusとトークンエコノミー実現への期待Hyperleger Tokyo Meetup
 
「関心の分離」と「疎結合」 ソフトウェアアーキテクチャのひとかけら
「関心の分離」と「疎結合」   ソフトウェアアーキテクチャのひとかけら「関心の分離」と「疎結合」   ソフトウェアアーキテクチャのひとかけら
「関心の分離」と「疎結合」 ソフトウェアアーキテクチャのひとかけらAtsushi Nakamura
 
GitHub 실습 교육
GitHub 실습 교육GitHub 실습 교육
GitHub 실습 교육승엽 신
 
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기Chris Ohk
 
エンタープライズブロックチェーン構築の基礎
エンタープライズブロックチェーン構築の基礎エンタープライズブロックチェーン構築の基礎
エンタープライズブロックチェーン構築の基礎Hyperleger Tokyo Meetup
 
AndroidアプリのKotlin移行時に遭遇した問題と対処例
AndroidアプリのKotlin移行時に遭遇した問題と対処例AndroidアプリのKotlin移行時に遭遇した問題と対処例
AndroidアプリのKotlin移行時に遭遇した問題と対処例Kenichi Kambara
 
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git민태 김
 
PostgreSQLの行レベルセキュリティと SpringAOPでマルチテナントの ユーザー間情報漏洩を防止する (JJUG CCC 2021 Spring)
PostgreSQLの行レベルセキュリティと SpringAOPでマルチテナントの ユーザー間情報漏洩を防止する (JJUG CCC 2021 Spring)PostgreSQLの行レベルセキュリティと SpringAOPでマルチテナントの ユーザー間情報漏洩を防止する (JJUG CCC 2021 Spring)
PostgreSQLの行レベルセキュリティと SpringAOPでマルチテナントの ユーザー間情報漏洩を防止する (JJUG CCC 2021 Spring)Koichiro Matsuoka
 
ゴシッププロトコルによる冗長化と負荷分散の検証
ゴシッププロトコルによる冗長化と負荷分散の検証ゴシッププロトコルによる冗長化と負荷分散の検証
ゴシッププロトコルによる冗長化と負荷分散の検証Sugawara Genki
 
파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥
파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥
파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥Seomgi Han
 
XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...
XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...
XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...Publicis Sapient Engineering
 
異種ブロックチェーン統合ツールHyperledger Cactiご紹介
異種ブロックチェーン統合ツールHyperledger Cactiご紹介異種ブロックチェーン統合ツールHyperledger Cactiご紹介
異種ブロックチェーン統合ツールHyperledger Cactiご紹介Hyperleger Tokyo Meetup
 

What's hot (20)

고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들
고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들
고려대학교 컴퓨터학과 특강 - 대학생 때 알았더라면 좋았을 것들
 
게임엔진과 공간정보 3D 콘텐츠 융합 : Cesium for Unreal
게임엔진과 공간정보 3D 콘텐츠 융합 : Cesium for Unreal게임엔진과 공간정보 3D 콘텐츠 융합 : Cesium for Unreal
게임엔진과 공간정보 3D 콘텐츠 융합 : Cesium for Unreal
 
はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化
はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化
はてなブックマークにおけるアクセス制御 - 半環構造に基づくモデル化
 
Goroutineと channelから はじめるgo言語
Goroutineと channelから はじめるgo言語Goroutineと channelから はじめるgo言語
Goroutineと channelから はじめるgo言語
 
ここがつらいよ、Hyperledger Fabricの商用適用(Blockchain GIG #4発表資料)
ここがつらいよ、Hyperledger Fabricの商用適用(Blockchain GIG #4発表資料) ここがつらいよ、Hyperledger Fabricの商用適用(Blockchain GIG #4発表資料)
ここがつらいよ、Hyperledger Fabricの商用適用(Blockchain GIG #4発表資料)
 
Dokkuの活用と内部構造
Dokkuの活用と内部構造Dokkuの活用と内部構造
Dokkuの活用と内部構造
 
20180711 Metamask
20180711 Metamask 20180711 Metamask
20180711 Metamask
 
3週連続DDDその2 深いモデルの探求(ドメイン駆動設計 第3部)
3週連続DDDその2  深いモデルの探求(ドメイン駆動設計 第3部)3週連続DDDその2  深いモデルの探求(ドメイン駆動設計 第3部)
3週連続DDDその2 深いモデルの探求(ドメイン駆動設計 第3部)
 
ブロックチェーン統合ツールCactusとトークンエコノミー実現への期待
ブロックチェーン統合ツールCactusとトークンエコノミー実現への期待ブロックチェーン統合ツールCactusとトークンエコノミー実現への期待
ブロックチェーン統合ツールCactusとトークンエコノミー実現への期待
 
「関心の分離」と「疎結合」 ソフトウェアアーキテクチャのひとかけら
「関心の分離」と「疎結合」   ソフトウェアアーキテクチャのひとかけら「関心の分離」と「疎結合」   ソフトウェアアーキテクチャのひとかけら
「関心の分離」と「疎結合」 ソフトウェアアーキテクチャのひとかけら
 
GitHub 실습 교육
GitHub 실습 교육GitHub 실습 교육
GitHub 실습 교육
 
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기
선린인터넷고등학교 2021 알고리즘 컨퍼런스 - Rust로 알고리즘 문제 풀어보기
 
エンタープライズブロックチェーン構築の基礎
エンタープライズブロックチェーン構築の基礎エンタープライズブロックチェーン構築の基礎
エンタープライズブロックチェーン構築の基礎
 
AndroidアプリのKotlin移行時に遭遇した問題と対処例
AndroidアプリのKotlin移行時に遭遇した問題と対処例AndroidアプリのKotlin移行時に遭遇した問題と対処例
AndroidアプリのKotlin移行時に遭遇した問題と対処例
 
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
버전관리를 들어본적 없는 사람들을 위한 DVCS - Git
 
PostgreSQLの行レベルセキュリティと SpringAOPでマルチテナントの ユーザー間情報漏洩を防止する (JJUG CCC 2021 Spring)
PostgreSQLの行レベルセキュリティと SpringAOPでマルチテナントの ユーザー間情報漏洩を防止する (JJUG CCC 2021 Spring)PostgreSQLの行レベルセキュリティと SpringAOPでマルチテナントの ユーザー間情報漏洩を防止する (JJUG CCC 2021 Spring)
PostgreSQLの行レベルセキュリティと SpringAOPでマルチテナントの ユーザー間情報漏洩を防止する (JJUG CCC 2021 Spring)
 
ゴシッププロトコルによる冗長化と負荷分散の検証
ゴシッププロトコルによる冗長化と負荷分散の検証ゴシッププロトコルによる冗長化と負荷分散の検証
ゴシッププロトコルによる冗長化と負荷分散の検証
 
파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥
파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥
파이콘 한국 2019 - 파이썬으로 서버를 극한까지 끌어다 쓰기: Async I/O의 밑바닥
 
XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...
XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...
XebiCon'18 - Utiliser Hyperledger Fabric pour la création d'une blockchain pr...
 
異種ブロックチェーン統合ツールHyperledger Cactiご紹介
異種ブロックチェーン統合ツールHyperledger Cactiご紹介異種ブロックチェーン統合ツールHyperledger Cactiご紹介
異種ブロックチェーン統合ツールHyperledger Cactiご紹介
 

Viewers also liked

GoによるiOSアプリの開発
GoによるiOSアプリの開発GoによるiOSアプリの開発
GoによるiOSアプリの開発Takuya Ueda
 
Mobile Apps by Pure Go with Reverse Binding
Mobile Apps by Pure Go with Reverse BindingMobile Apps by Pure Go with Reverse Binding
Mobile Apps by Pure Go with Reverse BindingTakuya Ueda
 
Go1.8 for Google App Engine
Go1.8 for Google App EngineGo1.8 for Google App Engine
Go1.8 for Google App EngineTakuya Ueda
 
HTTP2 RFC 発行記念祝賀会
HTTP2 RFC 発行記念祝賀会HTTP2 RFC 発行記念祝賀会
HTTP2 RFC 発行記念祝賀会Jxck Jxck
 
粗探しをしてGoのコントリビューターになる方法
粗探しをしてGoのコントリビューターになる方法粗探しをしてGoのコントリビューターになる方法
粗探しをしてGoのコントリビューターになる方法Takuya Ueda
 
条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化Takuya Ueda
 
Cloud Functionsの紹介
Cloud Functionsの紹介Cloud Functionsの紹介
Cloud Functionsの紹介Takuya Ueda
 
Namespace API を用いたマルチテナント型 Web アプリの実践
Namespace API を用いたマルチテナント型 Web アプリの実践Namespace API を用いたマルチテナント型 Web アプリの実践
Namespace API を用いたマルチテナント型 Web アプリの実践Takuya Ueda
 
Goにおける静的解析と製品開発への応用
Goにおける静的解析と製品開発への応用Goにおける静的解析と製品開発への応用
Goにおける静的解析と製品開発への応用Takuya Ueda
 
Go静的解析ハンズオン
Go静的解析ハンズオンGo静的解析ハンズオン
Go静的解析ハンズオンTakuya Ueda
 
うしちゃん WebRTC Chat on SkyWayの開発コードw
うしちゃん WebRTC Chat on SkyWayの開発コードwうしちゃん WebRTC Chat on SkyWayの開発コードw
うしちゃん WebRTC Chat on SkyWayの開発コードwKensaku Komatsu
 
Javaトラブルに備えよう #jjug_ccc #ccc_h2
Javaトラブルに備えよう #jjug_ccc #ccc_h2Javaトラブルに備えよう #jjug_ccc #ccc_h2
Javaトラブルに備えよう #jjug_ccc #ccc_h2Norito Agetsuma
 
goパッケージで型情報を用いたソースコード検索を実現する
goパッケージで型情報を用いたソースコード検索を実現するgoパッケージで型情報を用いたソースコード検索を実現する
goパッケージで型情報を用いたソースコード検索を実現するTakuya Ueda
 
静的解析とUIの自動生成を駆使してモバイルアプリの運用コストを大幅に下げた話
静的解析とUIの自動生成を駆使してモバイルアプリの運用コストを大幅に下げた話静的解析とUIの自動生成を駆使してモバイルアプリの運用コストを大幅に下げた話
静的解析とUIの自動生成を駆使してモバイルアプリの運用コストを大幅に下げた話Takuya Ueda
 
Cloud functionsの紹介
Cloud functionsの紹介Cloud functionsの紹介
Cloud functionsの紹介Takuya Ueda
 
メルカリ・ソウゾウでは どうGoを活用しているのか?
メルカリ・ソウゾウでは どうGoを活用しているのか?メルカリ・ソウゾウでは どうGoを活用しているのか?
メルカリ・ソウゾウでは どうGoを活用しているのか?Takuya Ueda
 
HTTP2 時代の Web - web over http2
HTTP2 時代の Web - web over http2HTTP2 時代の Web - web over http2
HTTP2 時代の Web - web over http2Jxck Jxck
 
オススメの標準・準標準パッケージ20選
オススメの標準・準標準パッケージ20選オススメの標準・準標準パッケージ20選
オススメの標準・準標準パッケージ20選Takuya Ueda
 
Google Assistant関係のセッションまとめ
Google Assistant関係のセッションまとめGoogle Assistant関係のセッションまとめ
Google Assistant関係のセッションまとめTakuya Ueda
 
WebRTC Browsers n Stacks Implementation differences
WebRTC Browsers n Stacks Implementation differencesWebRTC Browsers n Stacks Implementation differences
WebRTC Browsers n Stacks Implementation differencesAlexandre Gouaillard
 

Viewers also liked (20)

GoによるiOSアプリの開発
GoによるiOSアプリの開発GoによるiOSアプリの開発
GoによるiOSアプリの開発
 
Mobile Apps by Pure Go with Reverse Binding
Mobile Apps by Pure Go with Reverse BindingMobile Apps by Pure Go with Reverse Binding
Mobile Apps by Pure Go with Reverse Binding
 
Go1.8 for Google App Engine
Go1.8 for Google App EngineGo1.8 for Google App Engine
Go1.8 for Google App Engine
 
HTTP2 RFC 発行記念祝賀会
HTTP2 RFC 発行記念祝賀会HTTP2 RFC 発行記念祝賀会
HTTP2 RFC 発行記念祝賀会
 
粗探しをしてGoのコントリビューターになる方法
粗探しをしてGoのコントリビューターになる方法粗探しをしてGoのコントリビューターになる方法
粗探しをしてGoのコントリビューターになる方法
 
条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化条件式評価器の実装による管理ツールの抽象化
条件式評価器の実装による管理ツールの抽象化
 
Cloud Functionsの紹介
Cloud Functionsの紹介Cloud Functionsの紹介
Cloud Functionsの紹介
 
Namespace API を用いたマルチテナント型 Web アプリの実践
Namespace API を用いたマルチテナント型 Web アプリの実践Namespace API を用いたマルチテナント型 Web アプリの実践
Namespace API を用いたマルチテナント型 Web アプリの実践
 
Goにおける静的解析と製品開発への応用
Goにおける静的解析と製品開発への応用Goにおける静的解析と製品開発への応用
Goにおける静的解析と製品開発への応用
 
Go静的解析ハンズオン
Go静的解析ハンズオンGo静的解析ハンズオン
Go静的解析ハンズオン
 
うしちゃん WebRTC Chat on SkyWayの開発コードw
うしちゃん WebRTC Chat on SkyWayの開発コードwうしちゃん WebRTC Chat on SkyWayの開発コードw
うしちゃん WebRTC Chat on SkyWayの開発コードw
 
Javaトラブルに備えよう #jjug_ccc #ccc_h2
Javaトラブルに備えよう #jjug_ccc #ccc_h2Javaトラブルに備えよう #jjug_ccc #ccc_h2
Javaトラブルに備えよう #jjug_ccc #ccc_h2
 
goパッケージで型情報を用いたソースコード検索を実現する
goパッケージで型情報を用いたソースコード検索を実現するgoパッケージで型情報を用いたソースコード検索を実現する
goパッケージで型情報を用いたソースコード検索を実現する
 
静的解析とUIの自動生成を駆使してモバイルアプリの運用コストを大幅に下げた話
静的解析とUIの自動生成を駆使してモバイルアプリの運用コストを大幅に下げた話静的解析とUIの自動生成を駆使してモバイルアプリの運用コストを大幅に下げた話
静的解析とUIの自動生成を駆使してモバイルアプリの運用コストを大幅に下げた話
 
Cloud functionsの紹介
Cloud functionsの紹介Cloud functionsの紹介
Cloud functionsの紹介
 
メルカリ・ソウゾウでは どうGoを活用しているのか?
メルカリ・ソウゾウでは どうGoを活用しているのか?メルカリ・ソウゾウでは どうGoを活用しているのか?
メルカリ・ソウゾウでは どうGoを活用しているのか?
 
HTTP2 時代の Web - web over http2
HTTP2 時代の Web - web over http2HTTP2 時代の Web - web over http2
HTTP2 時代の Web - web over http2
 
オススメの標準・準標準パッケージ20選
オススメの標準・準標準パッケージ20選オススメの標準・準標準パッケージ20選
オススメの標準・準標準パッケージ20選
 
Google Assistant関係のセッションまとめ
Google Assistant関係のセッションまとめGoogle Assistant関係のセッションまとめ
Google Assistant関係のセッションまとめ
 
WebRTC Browsers n Stacks Implementation differences
WebRTC Browsers n Stacks Implementation differencesWebRTC Browsers n Stacks Implementation differences
WebRTC Browsers n Stacks Implementation differences
 

Similar to Static Analysis in Go

Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoRodolfo Carvalho
 
Python-GTK
Python-GTKPython-GTK
Python-GTKYuren Ju
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manualSami Said
 
Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Yuren Ju
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Robert Stern
 
Compact ordered dict__k_lab_meeting_
Compact ordered dict__k_lab_meeting_Compact ordered dict__k_lab_meeting_
Compact ordered dict__k_lab_meeting_miki koganei
 
Golang 101
Golang 101Golang 101
Golang 101宇 傅
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersAlessandro Sanino
 
An Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesAn Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesRay Toal
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard LibrarySantosh Rajan
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboyKenneth Geisshirt
 
Pseudo dynamic immutable records in C++
Pseudo dynamic immutable records in C++Pseudo dynamic immutable records in C++
Pseudo dynamic immutable records in C++ant_pt
 
Groovy AST Transformations
Groovy AST TransformationsGroovy AST Transformations
Groovy AST Transformationshendersk
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 

Similar to Static Analysis in Go (20)

Golang
GolangGolang
Golang
 
Go 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX GoGo 1.10 Release Party - PDX Go
Go 1.10 Release Party - PDX Go
 
Python-GTK
Python-GTKPython-GTK
Python-GTK
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
Python GTK (Hacking Camp)
Python GTK (Hacking Camp)Python GTK (Hacking Camp)
Python GTK (Hacking Camp)
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
 
JavaZone 2014 - goto java;
JavaZone 2014 - goto java;JavaZone 2014 - goto java;
JavaZone 2014 - goto java;
 
Compact ordered dict__k_lab_meeting_
Compact ordered dict__k_lab_meeting_Compact ordered dict__k_lab_meeting_
Compact ordered dict__k_lab_meeting_
 
Golang 101
Golang 101Golang 101
Golang 101
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
 
Vocabulary Types in C++17
Vocabulary Types in C++17Vocabulary Types in C++17
Vocabulary Types in C++17
 
Let's Go-lang
Let's Go-langLet's Go-lang
Let's Go-lang
 
An Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax TreesAn Annotation Framework for Statically-Typed Syntax Trees
An Annotation Framework for Statically-Typed Syntax Trees
 
The Swift Compiler and Standard Library
The Swift Compiler and Standard LibraryThe Swift Compiler and Standard Library
The Swift Compiler and Standard Library
 
Unleash your inner console cowboy
Unleash your inner console cowboyUnleash your inner console cowboy
Unleash your inner console cowboy
 
Pseudo dynamic immutable records in C++
Pseudo dynamic immutable records in C++Pseudo dynamic immutable records in C++
Pseudo dynamic immutable records in C++
 
Gunosy.go #4 go
Gunosy.go #4 goGunosy.go #4 go
Gunosy.go #4 go
 
Groovy AST Transformations
Groovy AST TransformationsGroovy AST Transformations
Groovy AST Transformations
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
Python basic
Python basicPython basic
Python basic
 

More from Takuya Ueda

Goにおけるバージョン管理の必要性 − vgoについて −
Goにおけるバージョン管理の必要性 − vgoについて −Goにおけるバージョン管理の必要性 − vgoについて −
Goにおけるバージョン管理の必要性 − vgoについて −Takuya Ueda
 
WebAssembly with Go
WebAssembly with GoWebAssembly with Go
WebAssembly with GoTakuya Ueda
 
GAE/Goとsyncパッケージ
GAE/GoとsyncパッケージGAE/Goとsyncパッケージ
GAE/GoとsyncパッケージTakuya Ueda
 
静的解析を使った開発ツールの開発
静的解析を使った開発ツールの開発静的解析を使った開発ツールの開発
静的解析を使った開発ツールの開発Takuya Ueda
 
そうだ、Goを始めよう
そうだ、Goを始めようそうだ、Goを始めよう
そうだ、Goを始めようTakuya Ueda
 
マスター・オブ・goパッケージ
マスター・オブ・goパッケージマスター・オブ・goパッケージ
マスター・オブ・goパッケージTakuya Ueda
 
メルカリ カウルのマスタデータの更新
メルカリ カウルのマスタデータの更新メルカリ カウルのマスタデータの更新
メルカリ カウルのマスタデータの更新Takuya Ueda
 
Go Friday 傑作選
Go Friday 傑作選Go Friday 傑作選
Go Friday 傑作選Takuya Ueda
 
エキスパートGo
エキスパートGoエキスパートGo
エキスパートGoTakuya Ueda
 
Gopher Fest 2017参加レポート
Gopher Fest 2017参加レポートGopher Fest 2017参加レポート
Gopher Fest 2017参加レポートTakuya Ueda
 
Goでかんたんソースコードの静的解析
Goでかんたんソースコードの静的解析Goでかんたんソースコードの静的解析
Goでかんたんソースコードの静的解析Takuya Ueda
 
Goでwebアプリを開発してみよう
Goでwebアプリを開発してみようGoでwebアプリを開発してみよう
Goでwebアプリを開発してみようTakuya Ueda
 
GAE/GoでWebアプリ開発入門
GAE/GoでWebアプリ開発入門GAE/GoでWebアプリ開発入門
GAE/GoでWebアプリ開発入門Takuya Ueda
 
GAE/GoでLINE Messaging API を使う
GAE/GoでLINE Messaging API を使うGAE/GoでLINE Messaging API を使う
GAE/GoでLINE Messaging API を使うTakuya Ueda
 
メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法
メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法
メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法Takuya Ueda
 

More from Takuya Ueda (15)

Goにおけるバージョン管理の必要性 − vgoについて −
Goにおけるバージョン管理の必要性 − vgoについて −Goにおけるバージョン管理の必要性 − vgoについて −
Goにおけるバージョン管理の必要性 − vgoについて −
 
WebAssembly with Go
WebAssembly with GoWebAssembly with Go
WebAssembly with Go
 
GAE/Goとsyncパッケージ
GAE/GoとsyncパッケージGAE/Goとsyncパッケージ
GAE/Goとsyncパッケージ
 
静的解析を使った開発ツールの開発
静的解析を使った開発ツールの開発静的解析を使った開発ツールの開発
静的解析を使った開発ツールの開発
 
そうだ、Goを始めよう
そうだ、Goを始めようそうだ、Goを始めよう
そうだ、Goを始めよう
 
マスター・オブ・goパッケージ
マスター・オブ・goパッケージマスター・オブ・goパッケージ
マスター・オブ・goパッケージ
 
メルカリ カウルのマスタデータの更新
メルカリ カウルのマスタデータの更新メルカリ カウルのマスタデータの更新
メルカリ カウルのマスタデータの更新
 
Go Friday 傑作選
Go Friday 傑作選Go Friday 傑作選
Go Friday 傑作選
 
エキスパートGo
エキスパートGoエキスパートGo
エキスパートGo
 
Gopher Fest 2017参加レポート
Gopher Fest 2017参加レポートGopher Fest 2017参加レポート
Gopher Fest 2017参加レポート
 
Goでかんたんソースコードの静的解析
Goでかんたんソースコードの静的解析Goでかんたんソースコードの静的解析
Goでかんたんソースコードの静的解析
 
Goでwebアプリを開発してみよう
Goでwebアプリを開発してみようGoでwebアプリを開発してみよう
Goでwebアプリを開発してみよう
 
GAE/GoでWebアプリ開発入門
GAE/GoでWebアプリ開発入門GAE/GoでWebアプリ開発入門
GAE/GoでWebアプリ開発入門
 
GAE/GoでLINE Messaging API を使う
GAE/GoでLINE Messaging API を使うGAE/GoでLINE Messaging API を使う
GAE/GoでLINE Messaging API を使う
 
メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法
メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法
メルカリアッテの実務で使えた、GAE/Goの開発を効率的にする方法
 

Recently uploaded

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Principled Technologies
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 

Recently uploaded (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 

Static Analysis in Go

  • 1. The Go gopher was designed by Renée French. The gopher stickers was made by Takuya Ueda. Licensed under the Creative Commons 3.0 Attributions license. Static Analysis in Go @GolangUK Conference 18th Aug. 2017 1
  • 2. Who am I? Takuya Ueda @tenntenn ➔ Work for ➔ Communities & Go Beginners in Tokyo Go Conference in Tokyo 2
  • 4. Who am I? Takuya Ueda @tenntenn ➔ Work for ➔ Communities & Go Beginners in Tokyo Go Conference in Tokyo 4
  • 5. Agenda ➔ Where’s Gopher? ➔ Static Analysis ➔ Static Analysis in Go ➔ Static Analysis for Products 5
  • 6. Where’s Gopher? Find Me!! Powered by https://gopherize.me 6
  • 7. Where’s Gopher? Find Me!! Powered by https://gopherize.me 7
  • 8. Where’s “Gopher”? type Gopher struct { Gopher string `json:"gopher"` } func main() { const gopher = "GOPHER" gogopher := GOPHER() gogopher.Gopher = gopher fmt.Println(gogopher) } func GOPHER() (gopher *Gopher) { gopher = &Gopher{ Gopher: "gopher" } return } 8
  • 9. We love grep $ grep Gopher main.go type Gopher struct { Gopher string `json:"gopher"` } gogopher.Gopher = gopher func GOPHER() (gopher *Gopher) { gopher = &Gopher{ Gopher: "gopher" } We can search “Gopher” with grep. 9
  • 10. Where’s “Gopher” TYPE? type Gopher struct { Gopher string `json:"gopher"` } func main() { const gopher = "GOPHER" gogopher := GOPHER() gogopher.Gopher = gopher fmt.Println(gogopher) } func GOPHER() (gopher *Gopher) { gopher = &Gopher{ Gopher: "gopher" } return } 10
  • 11. How to search “Gopher” type ➔ grep can search only by text ➔ The text must be understood as Go source code ➔ We need “Static Analysis” 11
  • 13. Static Analysis & Dynamic Analysis ➔ Static Analysis ◆ Analyzing a program WITHOUT execution ◆ Analyzing structure of a program from source codes ◆ e.g. linter, code complement, code formatter ➔ Dynamic Analysis ◆ Analyzing a program WITH execution ◆ Investigating variables and result of functions ◆ e.g. race detector 13
  • 14. Reflection ➔ Reflection ◆ Analyzing values and types at runtime. ➔ Reflection in Go ◆ reflect package ◆ It is only way to get struct tags at runtime ◆ encoding package uses reflection to encode/decode JSONs, XMLs and so on. 14
  • 15. Static Analysis Tools for Go ➔ There are many static analysis tools for Go gofmt/goimports code formatter go vet/golint code checker, linter guru code comprehension tool gocode code complement tool errcheck error handlings checker gorename/gomvpkg refactoring tools 15
  • 16. Go for Static Analysis ➔ Go is easy to static analyze ◆ Static typing ◆ Simple syntax ◆ Type inference ◆ No Implicit type conversion ◆ go package is provided as a standard package Static Analysis gives a lot of information 16
  • 17. Sub packages of go package ast Package ast declares the types used to represent syntax trees for Go packages. build Package build gathers information about Go packages. constant Package constant implements Values representing untyped Go constants and their corresponding operations. doc Package doc extracts source code documentation from a Go AST. format Package format implements standard formatting of Go source. importer Package importer provides access to export data importers. parser Package parser implements a parser for Go source files. printer Package printer implements printing of AST nodes. scanner Package scanner implements a scanner for Go source text. token Package token defines constants representing the lexical tokens of the Go programming language and basic operations on tokens (printing, predicates). types Package types declares the data types and implements the algorithms for type-checking of Go packages. 17
  • 19. Flow of Static Analysis Source Code Token Abstract Syntax Tree (AST) Type Info Parse Tokenize Type Check go/scanner go/token go/parser go/ast go/types go/constant 19
  • 20. Tokenization - go/scanner,go/token IDENT ADD INT Tokens Source Code: v + 1 ➔ Dividing input string into tokens 20
  • 21. Parsing - go/parser,go/ast ➔ Converting tokens to abstract syntax tree v + 1 IDENT ADD INT Source Code: + v 1 BinaryExpr Ident BasicLit Tokens: Abstract Syntax Tree: (AST) 21
  • 22. AST of “Hello, World” package main import "fmt" func main() { fmt.Println("Hello, 世界") } Run on Playground *ast.File []ast.Decl *ast.GenDecl *ast.FuncDecl 22
  • 23. Type Check - go/types,go/constant ➔ Extract type infomation from AST ◆ Identifier Resolution ◆ Type Detection ◆ Constant Evalution n := 100 + 200 m := n + 300 Constant Evalution = 300 Type Detection -> int Identifier Resolution 23
  • 24. Getting AST from source code ➔ Use parser.Parse* function ◆ ParseExpr,ParseExprFrom ● Parsing expression ● ParseExpr is simple version of ParseExprFrom ◆ ParseFile ● Parsing a file ◆ ParseDir ● Parsing files in a directory ● Calling ParseFile in the function 24
  • 25. Getting AST from an expression expr, err := parser.ParseExpr(`v + 1`) if err != nil { /* handling the error */ } /* use expr */ ➔ Parsing an expression 25
  • 26. Getting AST from a file const src = ` package main var v = 100 func main() { fmt.Println(v+1) }` fs := token.NewFileSet() f, err := parser.ParseFile(fs, "my.go", src, 0) if err != nil { /* handling the error */ } /* use f */ file name which is opened when src is nil Source Code Parsing Mode 26
  • 27. token.FileSet ➔ Recording positions on files ◆ The position (token.Pos) is represented by integer ◆ The value is unique among multiple files ◆ token.FileSet holds offset of each files ◆ The offsets are recorded at parsing ◆ token.FileSet is passed to parsing function as an output parameter type Pos int 27
  • 28. Demo 1: Parse and Dump an AST 28 https://youtu.be/lM1Pj6xYxZs
  • 29. Traversing AST - ast.Inspect ➔ Using ast.Inspect expr, _ := parser.ParseExpr(`v + 1`) ast.Inspect(expr, func(n ast.Node) bool { if n != nil { fmt.Printf("%Tn", n) } return true }) Traverse the AST *ast.BinaryExpr *ast.Ident *ast.BasicLit Run on Playground ast.Walk is more powerful and complex + v 1 BinaryExpr Ident BasicLit 29
  • 30. Traversing AST - Recursively func traverse(n ast.Node) { switch n := n.(type) { case *ast.Ident: fmt.Println(n.Name) case *ast.BinaryExpr: traverse(n.X) traverse(n.Y) case *ast.UnaryExpr: traverse(n.X) default: fmt.Println(n) } } print idetifyer’s name traverse each terms recursively switching by types Run on Playground traverse a term recursively 30
  • 31. Demo 2: Inspect identifiers 31 https://youtu.be/mpUgaaASvHo
  • 32. Type Checking /* initialize configs for type checking */ cfg := &types.Config{Importer: importer.Default()} info := &types.Info{ /* TODO: initialize maps which will hold results */ } pkg,err := cfg.Check("main", fs, []*ast.File{f}, info) if err != nil { /* handling the error */ } /* TODO: use pkg or info */ ➔ (*types.Config).Check do a type checking 32
  • 33. types.Info holds results of type checking type Info struct { // Types maps expressions to their types, and for constant // expressions, also their values. Types map[ast.Expr]TypeAndValue // Defs maps identifiers to the objects they define. Defs map[*ast.Ident]Object // Uses maps identifiers to the objects they denote. Uses map[*ast.Ident]Object // Implicits maps nodes to their implicitly declared objects, if any. Implicits map[ast.Node]Object // Selections maps selector expressions (excluding qualified identifiers) // to their corresponding selections. Selections map[*ast.SelectorExpr]*Selection // Scopes maps ast.Nodes to the scopes they define. Scopes map[ast.Node]*Scope // InitOrder is the list of package-level initializers in the order in which // they must be executed. InitOrder []*Initializer } 33
  • 34. Demo 3: Inspect Gopher type 34 https://youtu.be/AuSDtmiMaXI
  • 35. Static Analysis for Products Case 1: gpath,go-httpdoc 35
  • 36. go.mercari.io/go-httpdoc ➔ Generate API Docs from tests of handlers ◆ Just write tests of HTTP handlers ◆ gRPC and JSON RPC are supported 36
  • 37. Tests for requests and responses ➔ Requests (Responses) can be test by specifying fields and expected values, document for each fields validator.RequestBody(t, []httpdoc.TestCase{ {"Name", "tenntenn", "User Name"}, {"Attribute.Email", "tenntenn@example.com", "e-mail address"}, }, &createUserRequest{}) 37
  • 38. github.com/tenntenn/gpath ➔ Simplefy reflection of struct fields ◆ Reflecting by expression of selectors ◆ Easy to reflect complex struct value ◆ Supports maps and slices (but restricted) type Bar struct { N []int } type Foo struct { Bar *Bar } f := &Foo{ Bar: &Bar{ N: []int{100} }} v, _ := At(f, `Bar.N[0]`) fmt.Println(v) $ go run main.go 100 38
  • 39. Create own static analysis tools ➔ Reduce costs of code reviews by own tools ◆ Custimized linter for your project ◆ Detecting typical bugs with own tools ◆ You should pay your time for more important things ● algorithm, design, performance and so on 39
  • 40. Static Analysis in Production Case 2: Banner Tool 40
  • 41. Banner Tool ➔ A management tool of in-app banners In-App Banner A screenshot of our app (Mercari Atte) 41
  • 42. Banner Tool ➔ A management tool of in-app banners Banner Tool ● Delivery Conditions ● Response Getting Banners w/ OS, API Version List of Delivered Banners w/ Image URL, Destination URL, etc... Apps 42
  • 43. Evaluation of Delivery Conditions Getting Banners GET /banner/?os=1 String(os) == "1" Banner Image, etc... Delivery Condition: Banner Tool "1" == "1" true BIND EVAL ➔ Describing delivery conditions by a Go like expression ◆ Eval expressions with go package ◆ Using a function calling for describing a variable with a type 43
  • 44. Conclutions ➔ Static Analysis is EASY in Go ◆ static typing, simple syntax, go package, etc... ➔ go package can ◆ tokenize, parse and type check ➔ Static analysis in production ◆ own static analysis tools (e.g. gpath, go-httpdoc) ◆ web apps (e.g. Banner Tool) 44
  • 45. Thank you! twitter: @tenntenn Qiita: tenntenn connpass: tenntenn 45