Skip to content

Commit 786cf4a

Browse files
committed
add 'check' mode to build.pl
* go vet * golint
1 parent 462c8b2 commit 786cf4a

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

build.pl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
&build when "build";
2828
&webdev when "webdev";
2929
&release when "release";
30+
&check when "check";
3031
&help when ["-h", "help"];
3132
default {
3233
say "invalid mode: '$mode'";
@@ -46,6 +47,7 @@ sub help {
4647
build: build the binary for the actual platform
4748
webdev: start 'zfs-snap-diff' with the option to serve the frontend code from the 'webapp' directory
4849
release: build and create a zip for each supported platform under 'build-output/'
50+
check: run 'golint' and 'go vet' on the project
4951
help: show this help
5052
EOF
5153
}
@@ -74,6 +76,9 @@ sub build {
7476
#
7577
sub release {
7678

79+
# check source
80+
&check();
81+
7782
# get the version from git
7883
my $version = &git_describe();
7984

@@ -100,6 +105,32 @@ sub release {
100105
}
101106

102107

108+
#
109+
# check the project with 'golint' and 'go vet'
110+
#
111+
sub check {
112+
113+
#
114+
# run go vet -
115+
say "running go vet ...";
116+
system("go vet .") == 0 or exit 1;
117+
118+
if(system("type golint >/dev/null 2>&1") == 0){
119+
#
120+
# run golint and filter out warnings about 'bindata.go'
121+
say "running golint ...";
122+
my @golint = grep(!/^bindata.go/, qx{golint .});
123+
if($#golint != -1){
124+
say "ABORT!! golint warnings found: ";
125+
say @golint;
126+
exit 1;
127+
}
128+
} else {
129+
say "golint not found!";
130+
}
131+
}
132+
133+
103134
#
104135
# start 'zfs-snap-diff' with the option to serve the frontend code from the 'webapp' directory
105136
#

0 commit comments

Comments
 (0)