{"id":555,"date":"2019-07-01T14:50:37","date_gmt":"2019-07-01T05:50:37","guid":{"rendered":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2019\/07\/01\/metago"},"modified":"2019-07-01T14:50:37","modified_gmt":"2019-07-01T05:50:37","slug":"metago","status":"publish","type":"post","link":"https:\/\/p-corporate-blog-cms.mmmcorp.co.jp\/blog\/2019\/07\/01\/metago\/","title":{"rendered":"Go\u8a00\u8a9e\u3067\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0"},"content":{"rendered":"
YouTube\u306e\u30d7\u30ec\u30df\u30a2\u30e0\u4f1a\u54e1\u306b\u5165\u3063\u3066\u3057\u307e\u3044\u3001\u52d5\u753b\u3092\u898b\u308b\u6642\u9593\u304c\u307e\u3059\u307e\u3059\u5897\u3048\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002\u30a8\u30f3\u30b8\u30cb\u30a2\u306e\u5185\u5c71\u3067\u3059\u3002<\/p>\n
\u6700\u8fd1\u306e\u696d\u52d9\u3067\u306f\u3001Go\u8a00\u8a9e\u3092\u66f8\u3044\u3066\u3044\u307e\u3059\u3002\u8a00\u8a9e\u306e\u6a5f\u80fd\u306b\u3064\u3044\u3066\u306f\u7269\u8db3\u308a\u306a\u3055\u3092\u611f\u3058\u308b\u3053\u3068\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u308c\u3088\u308a\u3082\u30b7\u30f3\u30d7\u30eb\u3055\u304c\u7d50\u69cb\u6c17\u306b\u5165\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n
\u4eca\u56de\u306f\u3001Go\u8a00\u8a9e\u306e\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306b\u3064\u3044\u3066\u3001\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n
\u958b\u767a\u696d\u52d9\u3067\u306f\u3001\u4f3c\u305f\u3088\u3046\u306a\u5358\u7d14\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u4f55\u5ea6\u3082\u66f8\u304f\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\u30dc\u30a4\u30e9\u30fc\u30d7\u30ec\u30fc\u30c8\u3068\u547c\u3070\u308c\u308b\u3088\u3046\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002
\n\u305d\u306e\u3088\u3046\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u81ea\u52d5\u751f\u6210\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u3066\u3001\u52b9\u7387\u5316\u3059\u308b\u3053\u3068\u306f\u3088\u304f\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n
\u3053\u306e \u300c\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u751f\u6210\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u304f\u3053\u3068\u300d<\/strong> \u3092 \u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3068\u547c\u3073\u307e\u3059\u3002<\/p>\n \u7b46\u8005\u304c\u53c2\u52a0\u3057\u3066\u3044\u308b\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3067\u306f\u3001\u5b9f\u969b\u306b\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u3053\u3068\u3092\u884c\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n \u4f55\u5ea6\u3082\u5358\u7d14\u306a\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u66f8\u3044\u305f\u308a\u3001\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u8a18\u8ff0\u30df\u30b9\u3092\u6e1b\u3089\u3057\u305f\u308a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n \u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306f\u3001\u958b\u767a\u696d\u52d9\u3092\u52b9\u7387\u5316\u3059\u308b\u4e0a\u3067\u5f37\u529b\u306a\u624b\u6cd5\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n Go\u8a00\u8a9e\u3067\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u884c\u3046\u5834\u5408\u3001\u4ee5\u4e0b\u306e2\u7a2e\u985e\u306e\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n \u4eca\u56de\u306f\u3001\u5f8c\u8005\u306e go\/*\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u306f\u3001\u300cGo\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u69cb\u6587\u89e3\u6790\u3057\u3001\u64cd\u4f5c\u3092\u884c\u3046API\u300d\u304c\u63d0\u4f9b\u3055\u308c\u3066\u3044\u307e\u3059\u3002 \u4ee5\u4e0b\u304c\u5b9f\u884c\u7d50\u679c\u3067\u3059\u3002<\/p>\n \u300cast.BinaryExpr\u300d\u300cast.Indent\u300d\u300cOp\u300d\u300cast.UnaryExpr\u300d\u300cast.BasicLit\u300d\u306a\u3069\u3001 \u4eca\u56de\u306f\u5b9f\u4f8b\u3068\u3057\u3066__\u300c\u3042\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u542b\u307e\u308c\u3066\u3044\u308b\u3059\u3079\u3066\u306e\u95a2\u6570\u306e\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\u3059\u308b\u300d__\u3053\u3068\u3092\u8003\u3048\u3066\u307f\u307e\u3059\u3002<\/p>\n \u30b5\u30f3\u30d7\u30eb\u3068\u3057\u3066\u3001\u4ee5\u4e0b\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u89e3\u6790\u5bfe\u8c61\u3068\u3057\u307e\u3059\u3002<\/p>\n \u5b9f\u969b\u306b\u306f\u3001Fuga\u95a2\u6570 \u3068 Hoge\u95a2\u6570 \u306f\u5225\u3005\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u8a18\u8ff0\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n \u3053\u306e\u30b5\u30f3\u30d7\u30eb\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u69cb\u6587\u89e3\u6790\u3057\u305f\u7d50\u679c\u3092\u5358\u7d14\u306b\u51fa\u529b\u3057\u3066\u307f\u307e\u3059\u3002 \u4ee5\u4e0b\u304c\u51fa\u529b\u7d50\u679c\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n \u69cb\u6587\u89e3\u6790\u6728\u3092\u8868\u73fe\u3057\u3066\u3044\u308b\u69cb\u9020\u4f53\u304b\u3089\u3001\u5fc5\u8981\u306a\u60c5\u5831\u3060\u3051\u3092\u53d6\u308b\u969b\u306b\u3001\u3069\u306e\u3088\u3046\u306a\u69cb\u9020\u306b\u306a\u3063\u3066\u3044\u308b\u306e\u304b\u3092\u628a\u63e1\u3067\u304d\u308b\u3088\u3046\u306b\u3001\u4e0a\u8a18\u306e\u3088\u3046\u306b\u51fa\u529b\u3057\u3066\u307f\u308b\u306e\u304c\u304a\u3059\u3059\u3081\u3067\u3059\u3002<\/p>\n \u3042\u3068\u306f\u3001\u89e3\u6790\u7d50\u679c\u3092\u51fa\u529b\u3057\u305f\u3082\u306e\u3092\u898b\u306a\u304c\u3089\u3001\u6b32\u3057\u3044\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u51e6\u7406\u3092\u66f8\u3044\u3066\u3044\u304f\u306e\u307f\u3067\u3059\u3002 \u4ee5\u4e0b\u306f\u3001\u51fa\u529b\u7d50\u679c\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n \u751f\u306e\u89e3\u6790\u7d50\u679c\u3088\u308a\u3001\u95a2\u6570\u306e\u60c5\u5831\u3092\u53d6\u308a\u51fa\u3057\u3084\u3059\u3044\u5f62\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u601d\u3044\u307e\u3059\u3002 Go\u8a00\u8a9e\u3067\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u3092\u3059\u308b\u624b\u6cd5\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002\n
2\u7a2e\u985e\u306e\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0<\/h2>\n
\n
go\/*\u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u3088\u308b\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0<\/code>\u306b\u3064\u3044\u3066\u3001\u53d6\u308a\u4e0a\u3052\u307e\u3059\u3002<\/p>\n
go\/* \u30d1\u30c3\u30b1\u30fc\u30b8\u306b\u3088\u308b\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0<\/h2>\n
\n\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3001go\/parser\u306eParseExpr\u95a2\u6570<\/code>\u306bGo\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u6587\u5b57\u5217\u3068\u3057\u3066\u6e21\u3059\u3068\u3001\u69cb\u6587\u89e3\u6790\u304c\u884c\u308f\u308c\u307e\u3059\u3002<\/p>\n
package main\n\nimport (\n "fmt"\n "go\/parser"\n)\n\nfunc main() {\n expr, _ := parser.ParseExpr("a * -1")\n fmt.Printf("%#v", expr)\n}<\/code><\/pre>\n
*ast.BinaryExpr {\n. X: *ast.Ident {\n. . NamePos: 1\n. . Name: "a"\n. . Obj: *ast.Object {\n. . . Kind: bad\n. . . Name: ""\n. . }\n. }\n. OpPos: 3\n. Op: *\n. Y: *ast.UnaryExpr {\n. . OpPos: 5\n. . Op: -\n. . X: *ast.BasicLit {\n. . . ValuePos: 6\n. . . Kind: INT\n. . . Value: "1"\n. . }\n. }\n}<\/code><\/pre>\n
\n\u69cb\u9020\u4f53\u3084\u30e1\u30f3\u30d0\u5909\u6570\u306b\u3088\u3063\u3066\u3001Go\u306e\u69cb\u6587\u3092\u8868\u3057\u3066\u3044\u308b\u306e\u304c\u611f\u3058\u53d6\u308c\u308b\u3068\u601d\u3044\u307e\u3059\u3002
\n\u4e00\u756a\u6700\u521d\u306b\u73fe\u308c\u308bast.BinaryExpr\u69cb\u9020\u4f53<\/code>\u306f\u3001\uff12\u9805\u6f14\u7b97\u5b50\u3092\u8868\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n
\u89e3\u6790\u5bfe\u8c61\u306e\u30d7\u30ed\u30b0\u30e9\u30e0<\/h2>\n
\/\/ sample\/fuga.go\npackage sample\n\nimport "fmt"\n\ntype FugaArg struct {\n Message string\n}\n\nfunc Fuga(arg FugaArg) error {\n fmt.Println(arg.Message)\n return nil\n}\n\n\n\/\/ sample\/hoge.go\npackage sample\n\ntype HogeArg struct {\n Message string\n}\n\nfunc Hoge(arg *HogeArg) (string, error) {\n return arg.Message, nil\n}<\/code><\/pre>\n
\n\u30d1\u30c3\u30b1\u30fc\u30b8\u5185\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u69cb\u6587\u89e3\u6790\u3059\u308b\u306e\u3067\u3001parser.ParseDir<\/code>\u95a2\u6570\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n
func main() {\n packageName := "sample"\n OutputFuncFromPackage(packageName)\n}\n\nfunc OutputFuncFromPackage(packageName string) error {\n fset := token.NewFileSet()\n packages, err := parser.ParseDir(fset, packageName, nil, parser.Mode(0))\n if err != nil {\n return err\n }\n\n for _, pkg := range packages {\n ast.Inspect(pkg, func(n ast.Node) bool {\n if t, ok := n.(*ast.FuncDecl); ok {\n ast.Print(fset, t)\n fmt.Println()\n }\n return true\n })\n }\n\n return nil\n}<\/code><\/pre>\n
*ast.FuncDecl {\n. Name: *ast.Ident {\n. . NamePos: sample\/hoge.go:7:6\n. . Name: "Hoge"\n. . Obj: *ast.Object {\n. . . Kind: func\n. . . Name: "Hoge"\n. . . Decl: *(obj @ 0)\n. . }\n. }\n. Type: *ast.FuncType {\n. . Func: sample\/hoge.go:7:1\n. . Params: *ast.FieldList {\n. . . Opening: sample\/hoge.go:7:10\n. . . List: []*ast.Field (len = 1) {\n. . . . 0: *ast.Field {\n. . . . . Names: []*ast.Ident (len = 1) {\n. . . . . . 0: *ast.Ident {\n. . . . . . . NamePos: sample\/hoge.go:7:11\n. . . . . . . Name: "arg"\n. . . . . . . Obj: *ast.Object {\n. . . . . . . . Kind: var\n. . . . . . . . Name: "arg"\n. . . . . . . . Decl: *(obj @ 15)\n. . . . . . . }\n. . . . . . }\n. . . . . }\n. . . . . Type: *ast.StarExpr {\n. . . . . . Star: sample\/hoge.go:7:15\n. . . . . . X: *ast.Ident {\n. . . . . . . NamePos: sample\/hoge.go:7:16\n. . . . . . . Name: "HogeArg"\n. . . . . . . Obj: *ast.Object {\n. . . . . . . . Kind: type\n. . . . . . . . Name: "HogeArg"\n. . . . . . . . Decl: *ast.TypeSpec {\n. . . . . . . . . Name: *ast.Ident {\n. . . . . . . . . . NamePos: sample\/hoge.go:3:6\n. . . . . . . . . . Name: "HogeArg"\n. . . . . . . . . . Obj: *(obj @ 32)\n. . . . . . . . . }\n. . . . . . . . . Assign: -\n. . . . . . . . . Type: *ast.StructType {\n. . . . . . . . . . Struct: sample\/hoge.go:3:14\n. . . . . . . . . . Fields: *ast.FieldList {\n. . . . . . . . . . . Opening: sample\/hoge.go:3:21\n. . . . . . . . . . . List: []*ast.Field (len = 1) {\n. . . . . . . . . . . . 0: *ast.Field {\n. . . . . . . . . . . . . Names: []*ast.Ident (len = 1) {\n. . . . . . . . . . . . . . 0: *ast.Ident {\n. . . . . . . . . . . . . . . NamePos: sample\/hoge.go:4:2\n. . . . . . . . . . . . . . . Name: "Message"\n. . . . . . . . . . . . . . . Obj: *ast.Object {\n. . . . . . . . . . . . . . . . Kind: var\n. . . . . . . . . . . . . . . . Name: "Message"\n. . . . . . . . . . . . . . . . Decl: *(obj @ 47)\n. . . . . . . . . . . . . . . }\n. . . . . . . . . . . . . . }\n. . . . . . . . . . . . . }\n. . . . . . . . . . . . . Type: *ast.Ident {\n. . . . . . . . . . . . . . NamePos: sample\/hoge.go:4:10\n. . . . . . . . . . . . . . Name: "string"\n. . . . . . . . . . . . . }\n. . . . . . . . . . . . }\n. . . . . . . . . . . }\n. . . . . . . . . . . Closing: sample\/hoge.go:5:1\n. . . . . . . . . . }\n. . . . . . . . . . Incomplete: false\n. . . . . . . . . }\n. . . . . . . . }\n. . . . . . . }\n. . . . . . }\n. . . . . }\n. . . . }\n. . . }\n. . . Closing: sample\/hoge.go:7:23\n. . }\n. . Results: *ast.FieldList {\n. . . Opening: sample\/hoge.go:7:25\n. . . List: []*ast.Field (len = 2) {\n. . . . 0: *ast.Field {\n. . . . . Type: *ast.Ident {\n. . . . . . NamePos: sample\/hoge.go:7:26\n. . . . . . Name: "string"\n. . . . . }\n. . . . }\n. . . . 1: *ast.Field {\n. . . . . Type: *ast.Ident {\n. . . . . . NamePos: sample\/hoge.go:7:34\n. . . . . . Name: "error"\n. . . . . }\n. . . . }\n. . . }\n. . . Closing: sample\/hoge.go:7:39\n. . }\n. }\n. Body: *ast.BlockStmt {\n. . Lbrace: sample\/hoge.go:7:41\n. . List: []ast.Stmt (len = 1) {\n. . . 0: *ast.ReturnStmt {\n. . . . Return: sample\/hoge.go:8:2\n. . . . Results: []ast.Expr (len = 2) {\n. . . . . 0: *ast.SelectorExpr {\n. . . . . . X: *ast.Ident {\n. . . . . . . NamePos: sample\/hoge.go:8:9\n. . . . . . . Name: "arg"\n. . . . . . . Obj: *(obj @ 20)\n. . . . . . }\n. . . . . . Sel: *ast.Ident {\n. . . . . . . NamePos: sample\/hoge.go:8:13\n. . . . . . . Name: "Message"\n. . . . . . }\n. . . . . }\n. . . . . 1: *ast.Ident {\n. . . . . . NamePos: sample\/hoge.go:8:22\n. . . . . . Name: "nil"\n. . . . . }\n. . . . }\n. . . }\n. . }\n. . Rbrace: sample\/hoge.go:9:1\n. }\n}<\/code><\/pre>\n
\u95a2\u6570\u60c5\u5831\u3092\u53d6\u308a\u51fa\u3059\u51e6\u7406<\/h2>\n
\n\u4ee5\u4e0b\u306f\u3001\u95a2\u6570\u306e\u4e00\u89a7\u3092\u53d6\u5f97\u3059\u308b\u51e6\u7406\u3092\u884c\u3046\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\u3002<\/p>\nfunc main() {\n packageName := "sample"\n funcs, err := GetFuncFromPackage(packageName)\n if err != nil {\n panic(err)\n }\n pp.Println(funcs)\n}\n\ntype GoFunc struct {\n FuncName string\n Args []*GoFuncArg\n Returns []string\n}\n\ntype GoFuncArg struct {\n Name []string\n Type string\n}\n\nfunc GetFuncArgTypeStr(t ast.Expr) string {\n typeStr := ""\n var symbols []string\n ast.Inspect(t, func(n ast.Node) bool {\n switch n.(type) {\n case *ast.SelectorExpr:\n sel := n.(*ast.SelectorExpr)\n typeStr = fmt.Sprintf("%s.%s", sel.X, sel.Sel.Name)\n case *ast.Ident:\n if typeStr == "" {\n typeStr = n.(*ast.Ident).Name\n }\n case *ast.InterfaceType:\n typeStr = "interface{}"\n case *ast.ArrayType:\n symbols = append(symbols, "[]")\n case *ast.MapType:\n m := n.(*ast.MapType)\n typeStr = fmt.Sprintf("map[%s]%s", m.Key, m.Value)\n case *ast.StarExpr:\n symbols = append(symbols, "*")\n }\n return true\n })\n\n return fmt.Sprintf("%s%s", strings.Join(symbols, ""), typeStr)\n}\n\nfunc GetFuncFromPackage(packageName string) ([]*GoFunc, error) {\n fset := token.NewFileSet()\n packages, err := parser.ParseDir(fset, packageName, nil, parser.Mode(0))\n if err != nil {\n return nil, err\n }\n\n var funcs []*GoFunc\n\n for _, pkg := range packages {\n ast.Inspect(pkg, func(n ast.Node) bool {\n if t, ok := n.(*ast.FuncDecl); ok {\n\n \/\/ \u30e1\u30bd\u30c3\u30c9 \u306f\u9664\u5916\n if t.Recv != nil {\n return true\n }\n\n \/\/ \u30c6\u30b9\u30c8 \u306f\u9664\u5916\n if strings.HasPrefix(t.Name.Name, "Test") {\n return true\n }\n\n \/\/ \u95a2\u6570\u306e\u5f15\u6570\u60c5\u5831\n var argDecls = make([]*GoFuncArg, len(t.Type.Params.List))\n for i, l := range t.Type.Params.List {\n\n \/\/ (a, b string, c int) \u306e\u3088\u3046\u306a\u5f15\u6570\u3060\u3063\u305f\u5834\u5408\u3001\n \/\/ [a, b] \u3068 [c] \u306e\u3088\u3046\u306a\u914d\u5217\u3067\u540d\u524d\u304c\u8fd4\u3063\u3066\u304f\u308b\n var names = make([]string, len(l.Names))\n for i := range l.Names {\n names[i] = l.Names[i].Name\n }\n\n \/\/ \u5f15\u6570\u306e\u578b\u60c5\u5831\u3092\u53d6\u5f97\n typeStr := GetFuncArgTypeStr(l.Type)\n\n \/\/ testing.T\u306a\u3069\u306e\u30c6\u30b9\u30c8\u95a2\u6570\u3067\u5b9a\u7fa9\u3055\u308c\u308b\u5f15\u6570\u3060\u3063\u305f\u5834\u5408\u306f\u9664\u5916\u3059\u308b\n if strings.HasSuffix(typeStr, ".T") {\n return true\n }\n\n \/\/ \u5f15\u6570\u60c5\u5831\u3092\u7c21\u5358\u306b\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u69cb\u9020\u4f53\u306b\u4fdd\u5b58\u3057\u3066\u304a\u304f\n argDecls[i] = &GoFuncArg{\n Name: names,\n Type: typeStr,\n }\n }\n\n \/\/ \u95a2\u6570\u306e\u8fd4\u308a\u5024\u60c5\u5831\n retStr := ""\n var retDecls []string\n if t.Type.Results != nil {\n\n \/\/ (int, float, string) \u306e\u3088\u3046\u306a\u8fd4\u308a\u5024\u306e\u578b\u60c5\u5831\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\u3059\u308b\n retDecls = make([]string, len(t.Type.Results.List))\n for i, l := range t.Type.Results.List {\n \/\/ \u5f15\u6570\u306e\u578b\u60c5\u5831\u3092\u53d6\u5f97\n retDecls[i] = GetFuncArgTypeStr(l.Type)\n }\n\n if len(retDecls) != 0 {\n retStr = strings.Join(retDecls, ", ")\n \/\/ \u8fd4\u308a\u5024\u304c\uff12\u3064\u4ee5\u4e0a\u306e\u5834\u5408\u306f\u3001 (int, float) \u306e\u3088\u3046\u306b\u30ab\u30c3\u30b3\u3092\u4ed8\u3051\u308b\n if len(retDecls) > 1 {\n retStr = fmt.Sprintf("(%s)", retStr)\n }\n }\n }\n\n \/\/ \u95a2\u6570\u60c5\u5831\u3092\u7c21\u5358\u306b\u53c2\u7167\u3067\u304d\u308b\u3088\u3046\u306b\u3057\u305f\u69cb\u9020\u4f53\u306b\u4fdd\u5b58\u3057\u3066\u304a\u304f\n funcs = append(funcs, &GoFunc{\n FuncName: t.Name.Name, \/\/ \u95a2\u6570\u540d\n Args: argDecls, \/\/ \u95a2\u6570\u306e\u5f15\u6570\u60c5\u5831\n Returns: retDecls, \/\/ \u95a2\u6570\u306e\u8fd4\u308a\u5024\u60c5\u5831\n })\n }\n return true\n })\n }\n\n return funcs, nil\n}\n<\/code><\/pre>\n
[]*main.GoFunc{\n &main.GoFunc{\n FuncName: "Hoge",\n Args: []*main.GoFuncArg{\n &main.GoFuncArg{\n Name: []string{\n "arg",\n },\n Type: "*HogeArg",\n },\n },\n Returns: []string{\n "string",\n "error",\n },\n },\n &main.GoFunc{\n FuncName: "Fuga",\n Args: []*main.GoFuncArg{\n &main.GoFuncArg{\n Name: []string{\n "arg",\n },\n Type: "FugaArg",\n },\n },\n Returns: []string{\n "error",\n },\n },\n}<\/code><\/pre>\n
\n\u3053\u306e\u60c5\u5831\u3092\u57fa\u306b\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u751f\u6210\u3059\u308b\u51e6\u7406\u3092\u66f8\u3044\u3066\u3044\u304f\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\u307e\u3068\u3081<\/h2>\n
\n\u30e1\u30bf\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u306f\u300c\u9ed2\u9b54\u8853\u300d\u3068\u547c\u3070\u308c\u308b\u3053\u3068\u3082\u3042\u308a\u3001\u53d6\u308a\u6271\u3044\u306b\u306f\u6ce8\u610f\u304c\u5fc5\u8981\u3067\u3059\u3002
\n\u3057\u304b\u3057\u3001\u3046\u307e\u304f\u884c\u3051\u3070\u958b\u767a\u696d\u52d9\u306e\u52b9\u7387\u5316\u306b\u7e4b\u304c\u308a\u307e\u3059\u3002
\n\u305c\u3072\u3068\u3082\u6311\u6226\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\u53c2\u8003\u30ea\u30f3\u30af<\/h2>\n