diff options
author | Ting-Wei Lan <tingwei.lan@cobinhood.com> | 2019-04-16 18:36:27 +0800 |
---|---|---|
committer | Ting-Wei Lan <tingwei.lan@cobinhood.com> | 2019-05-14 11:04:15 +0800 |
commit | d1a4d441c8121dd92d19054ef3ec6995f0974957 (patch) | |
tree | d8dbd674f5a28ad60787a54a62b3223f445cc6ce /build/ci.go | |
parent | 2d877e154c31f2cc63456aa47ec5eaebe416ce94 (diff) | |
download | dexon-d1a4d441c8121dd92d19054ef3ec6995f0974957.tar dexon-d1a4d441c8121dd92d19054ef3ec6995f0974957.tar.gz dexon-d1a4d441c8121dd92d19054ef3ec6995f0974957.tar.bz2 dexon-d1a4d441c8121dd92d19054ef3ec6995f0974957.tar.lz dexon-d1a4d441c8121dd92d19054ef3ec6995f0974957.tar.xz dexon-d1a4d441c8121dd92d19054ef3ec6995f0974957.tar.zst dexon-d1a4d441c8121dd92d19054ef3ec6995f0974957.zip |
core: vm: sqlvm: introduce go-sumtype
We have many interfaces decalred as a part of AST. Most of them are used
in a way called 'sum type', a type which is a collection of other types.
Since Go does not have a builtin way to check whether a type switch is
exhaustive, we add a static analysis tool called 'go-sumtype' to the CI
process to ensure we never hit the default panic case at runtime.
Since each interface must have at least a unique unexported method to
be considered as a valid sum type, we need a naming convention here.
Currently a unique name is created by putting ˉ character in front of
the name of the interface.
Remove Value function from Valuer interface declaration because the AST
printer has switched to reflection instead of using this interface. It
is not expected to have new users of Value functions because it returns
an empty interface. Type assertion is still required to access the value
and it is just clearer to assert the type of the AST node.
Remove AnyValueNode and DefaultValueNode from ExprNode. It is invalid to
use them as a part of an expression, and putting them in ExprNode just
makes type switches unreliable. Data types allocated for them are also
removed because non-expression nodes don't need data types.
Introduce InsertOptionNode and ColumnConstraintNode interfaces as sum
types. We used to use the generic Node interface to store them. Create
specific sum types enables go-sumtype to check type switches statically.
Drop assertNodeSlice because all callers are gone.
Diffstat (limited to 'build/ci.go')
-rw-r--r-- | build/ci.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/build/ci.go b/build/ci.go index 931fa2f83..e2b3445b8 100644 --- a/build/ci.go +++ b/build/ci.go @@ -377,6 +377,9 @@ func doLint(cmdline []string) { build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v2")) build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), "--install") + // Get go-sumtype. + build.MustRun(goTool("get", "github.com/BurntSushi/go-sumtype")) + // Run fast linters batched together configs := []string{ "--vendor", @@ -398,6 +401,9 @@ func doLint(cmdline []string) { configs = []string{"--vendor", "--tests", "--deadline=10m", "--disable-all", "--enable=" + linter} build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...) } + + // Run go-sumtype. + build.MustRunCommand(filepath.Join(GOBIN, "go-sumtype"), packages...) } // Release Packaging |