13.
AST
chunk, err := parse.Parse(f, fn)
if err := nil {panic(err)}
for _, s := range chunk {
if fs, ok := s.(*ast.FuncDefStmt); ok {
if fe, ok := fs.Name.Func.(*ast.IdentExpr); ok {
fmt.Print(fe.Value)
}
}
}
AST([]ast.Stmt)を取得
関数名を取得
関数宣言?
識別子
17.
Luaを使って設定ファイルを書く
-- config.lua
local config = {}
for i = 0, 4 do
table.insert(config, {
host = “localhost”,
port = 8080 + i,
})
end
return config
もちろんforも使える
Be the first to comment