what's goa?
goa は Go でマイクロサービスを構築する総体的なアプローチです。
The goa API Design Language is a DSL implemented in Go that makes it possible to describe arbitrary microservice APIs.
雑に言うとgoaはgoで実装されたDSLです。
https://goa.design/ja/
https://github.com/goadesign/goa
何で躓いたのか
terminal
# Add project folder
❯ cd <path/to/workspace>
❯ mkdir <project>
❯ cd <project>
# manage project
❯ dep init
# dep ensure -addでエラーが出るので予めmain.goを作成しておく
# error: all dirs lacked any go code
❯ touch main.go
# add goa by dep.
❯ dep ensure -add github.com/goadesign/goa/goagen
❯ dep ensure -v
# designがあれば書く
# 躓きポイント
# code生成のための準備でコケる
# depで入れた場合は、goagenをbuildする必要がある。
# うまくbuildできない(2018/07/23時点)
# goagenがいない場合は下記のtomlファイルを参考に requiredに対象を突っ込む
❯ cd vendor/github.com/goadesign/goa/goagen
❯ go build
# github.com/paveg/<project>/vendor/github.com/goadesign/goa/design
../design/random.go:64:18: not enough arguments in call to uuid.Must
have (uuid.UUID)
want (uuid.UUID, error)
go.uuid 此奴が吐くエラーで躓いた。
https://github.com/satori/go.uuid/issues/70
../design/random.go:64:18: not enough arguments in call to uuid.Must
have (uuid.UUID)
want (uuid.UUID, error)
とりあえず、 go.uuidはrevisionをオーバーライドしてmasterを見せておけば良いみたい
実設定
Gopkg.toml
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
required = ["github.com/goadesign/goa/goagen"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
#
# [prune]
# non-go = false
# go-tests = true
# unused-packages = true
[prune]
go-tests = true
unused-packages = true
[[constraint]]
name = "github.com/goadesign/goa"
version = "1.4.0"
[[override]]
name = "github.com/satori/go.uuid"
revision = "master"
Gopkg.lock
# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'.
[[projects]]
branch = "master"
name = "github.com/dimfeld/httppath"
packages = ["."]
revision = "ee938bf735983d53694d79138ad9820efff94c92"
[[projects]]
name = "github.com/goadesign/goa"
packages = [
"design",
"design/apidsl",
"dslengine",
"goagen",
"goagen/codegen",
"goagen/meta",
"goagen/utils",
"version"
]
revision = "e01bb31dd9403fa9d40747e1f93345bc96ea675e"
version = "v1.4.0"
[[projects]]
name = "github.com/inconshreveable/mousetrap"
packages = ["."]
revision = "76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"
version = "v1.0"
[[projects]]
branch = "master"
name = "github.com/manveru/faker"
packages = ["."]
revision = "9fbc68a78c4dbc7914e1a23f88f126bea4383b97"
[[projects]]
name = "github.com/satori/go.uuid"
packages = ["."]
revision = "master"
[[projects]]
name = "github.com/spf13/cobra"
packages = ["."]
revision = "ef82de70bb3f60c65fb8eebacbb2d122ef517385"
version = "v0.0.3"
[[projects]]
name = "github.com/spf13/pflag"
packages = ["."]
revision = "583c0c0531f06d5278b7d917446061adc344b5cd"
version = "v1.0.1"
[[projects]]
branch = "master"
name = "github.com/zach-klippenstein/goregen"
packages = ["."]
revision = "795b5e3961ea1912fde60af417ad85e86acc0d6a"
[[projects]]
branch = "master"
name = "golang.org/x/tools"
packages = ["go/ast/astutil"]
revision = "60ffea201e66e0d9375dc5bec85245d7b416710f"
[[projects]]
name = "gopkg.in/yaml.v2"
packages = ["."]
revision = "5420a8b6744d3b0345ab293f6fcba19c978f1183"
version = "v2.2.1"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1
inputs-digest = "ea9b480d129227a9604517419baecb5e6e0d9f3f1b05f08d2cb12654a33713a4"
solver-name = "gps-cdcl"
solver-version = 1