-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #939 from Lomanic/mktypes-gofmt
Make mktypes.sh generate go-fmt-ed code and make it shellcheck-compliant
- Loading branch information
Showing
1 changed file
with
11 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,16 @@ | ||
#!/bin/sh | ||
|
||
DIRS="cpu disk docker host load mem net process" | ||
PKGS="cpu disk docker host load mem net process" | ||
|
||
GOOS=`uname | tr '[:upper:]' '[:lower:]'` | ||
ARCH=`uname -m` | ||
GOOS=$(go env GOOS) | ||
GOARCH=$(go env GOARCH) | ||
GOARCH=$(go env GOARCH) | ||
|
||
case $ARCH in | ||
amd64) | ||
GOARCH="amd64" | ||
;; | ||
x86_64) | ||
GOARCH="amd64" | ||
;; | ||
i386) | ||
GOARCH="386" | ||
;; | ||
i686) | ||
GOARCH="386" | ||
;; | ||
arm) | ||
GOARCH="arm" | ||
;; | ||
arm64) | ||
GOARCH="arm64" | ||
;; | ||
*) | ||
echo "unknown arch: $ARCH" | ||
exit 1 | ||
esac | ||
|
||
for DIR in $DIRS | ||
for PKG in $PKGS | ||
do | ||
if [ -e ${DIR}/types_${GOOS}.go ]; then | ||
echo "// +build $GOOS" > ${DIR}/${DIR}_${GOOS}_${GOARCH}.go | ||
echo "// +build $GOARCH" >> ${DIR}/${DIR}_${GOOS}_${GOARCH}.go | ||
go tool cgo -godefs ${DIR}/types_${GOOS}.go >> ${DIR}/${DIR}_${GOOS}_${GOARCH}.go | ||
fi | ||
if [ -e "${PKG}/types_${GOOS}.go" ]; then | ||
(echo "// +build $GOOS" | ||
echo "// +build $GOARCH" | ||
go tool cgo -godefs "${PKG}/types_${GOOS}.go") | gofmt > "${PKG}/${PKG}_${GOOS}_${GOARCH}.go" | ||
fi | ||
done | ||
|
||
|