-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor code Signed-off-by: mritd <[email protected]>
- Loading branch information
Showing
6 changed files
with
567 additions
and
111 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
DIST_PREFIX="idgen" | ||
TARGET_DIR="dist" | ||
PLATFORMS="darwin/amd64 darwin/arm64 linux/386 linux/amd64 linux/arm linux/arm64" | ||
|
||
BUILD_VERSION=$(cat version) | ||
BUILD_DATE=$(date "+%F %T") | ||
COMMIT_SHA1=$(git rev-parse HEAD) | ||
|
||
rm -rf ${TARGET_DIR} | ||
mkdir ${TARGET_DIR} | ||
|
||
for pl in ${PLATFORMS}; do | ||
export GOOS=$(echo ${pl} | cut -d'/' -f1) | ||
export GOARCH=$(echo ${pl} | cut -d'/' -f2) | ||
export CGO_ENABLED=0 | ||
export TARGET=${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH} | ||
if [ "${GOOS}" == "windows" ]; then | ||
export TARGET=${TARGET_DIR}/${DIST_PREFIX}_${GOOS}_${GOARCH}.exe | ||
fi | ||
|
||
echo "build => ${TARGET}" | ||
go build -trimpath -o ${TARGET} \ | ||
-ldflags "-X 'github.com/mritd/idgen/cmd.Version=${BUILD_VERSION}' \ | ||
-X 'github.com/mritd/idgen/cmd.BuildDate=${BUILD_DATE}' \ | ||
-X 'github.com/mritd/idgen/cmd.CommitID=${COMMIT_SHA1}'\ | ||
-w -s" | ||
done | ||
|
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,12 +1,9 @@ | ||
FROM golang:1.14.2-alpine3.11 AS builder | ||
FROM golang:1.16-alpine AS builder | ||
|
||
COPY . /go/src/github.com/mritd/idgen | ||
|
||
WORKDIR /go/src/github.com/mritd/idgen | ||
|
||
ENV GO111MODULE on | ||
ENV GOPROXY https://goproxy.cn | ||
|
||
RUN set -ex \ | ||
&& apk upgrade \ | ||
&& apk add git \ | ||
|
@@ -19,7 +16,7 @@ RUN set -ex \ | |
-X 'github.com/mritd/idgen/cmd.BuildDate=${BUILD_DATE}' \ | ||
-X 'github.com/mritd/idgen/cmd.CommitID=${COMMIT_SHA1}'" | ||
|
||
FROM alpine:3.11 AS dist | ||
FROM alpine AS dist | ||
|
||
LABEL maintainer="mritd <[email protected]>" | ||
|
||
|
@@ -37,4 +34,5 @@ RUN set -ex \ | |
COPY --from=builder /go/bin/idgen /usr/bin/idgen | ||
|
||
ENTRYPOINT ["idgen"] | ||
|
||
CMD ["server"] |
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
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,9 +1,9 @@ | ||
module github.com/mritd/idgen | ||
|
||
go 1.14 | ||
go 1.16 | ||
|
||
require ( | ||
github.com/atotto/clipboard v0.1.2 | ||
github.com/mritd/chinaid v1.0.2 | ||
github.com/spf13/cobra v1.0.0 | ||
github.com/atotto/clipboard v0.1.4 | ||
github.com/mritd/chinaid v1.0.3 | ||
github.com/spf13/cobra v1.2.1 | ||
) |
Oops, something went wrong.