mirror of https://github.com/goproxyio/goproxy
compatible for go 1.11 and go 1.12
parent
c8a38458f3
commit
add79fbe31
|
@ -2,11 +2,21 @@
|
||||||
|
|
||||||
PKG="${PWD}/internal"
|
PKG="${PWD}/internal"
|
||||||
GOROOT="$(go env GOROOT)"
|
GOROOT="$(go env GOROOT)"
|
||||||
|
GOVERSION=`go version | awk -F ' ' '{print $3}'|grep '1.12'`
|
||||||
|
GTGO12=0
|
||||||
|
echo "ENV GOLANG VER: $GOVERSION"
|
||||||
|
|
||||||
|
if [[ "$GOVERSION" != "" ]]
|
||||||
|
then
|
||||||
|
GTGO12=1
|
||||||
|
echo "use 1.12 mode"
|
||||||
|
else
|
||||||
|
echo "use 1.11 mode"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "${PKG}"
|
mkdir -p "${PKG}"
|
||||||
cp -r "${GOROOT}/src/cmd/go/internal/"* "${PKG}"
|
cp -r "${GOROOT}/src/cmd/go/internal/"* "${PKG}"
|
||||||
|
|
||||||
|
|
||||||
cp -r "${GOROOT}/src/cmd/internal/browser" "${PKG}"
|
cp -r "${GOROOT}/src/cmd/internal/browser" "${PKG}"
|
||||||
cp -r "${GOROOT}/src/cmd/internal/buildid" "${PKG}"
|
cp -r "${GOROOT}/src/cmd/internal/buildid" "${PKG}"
|
||||||
cp -r "${GOROOT}/src/cmd/internal/objabi" "${PKG}"
|
cp -r "${GOROOT}/src/cmd/internal/objabi" "${PKG}"
|
||||||
|
@ -15,8 +25,20 @@ cp -r "${GOROOT}/src/cmd/internal/test2json" "${PKG}"
|
||||||
cp -r "${GOROOT}/src/internal/singleflight" "${PKG}"
|
cp -r "${GOROOT}/src/internal/singleflight" "${PKG}"
|
||||||
cp -r "${GOROOT}/src/internal/testenv" "${PKG}"
|
cp -r "${GOROOT}/src/internal/testenv" "${PKG}"
|
||||||
|
|
||||||
|
if [[ "$GTGO12" = "1" ]]
|
||||||
|
then
|
||||||
|
cp -r "${GOROOT}/src/internal/xcoff" "${PKG}"
|
||||||
|
cp -r "${GOROOT}/src/internal/goroot" "${PKG}"
|
||||||
|
cp -r "${GOROOT}/src/cmd/internal/sys" "${PKG}"
|
||||||
|
fi
|
||||||
|
|
||||||
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/cmd\/go\/internal/github.com\/goproxyio\/goproxy\/internal/g' {} +
|
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/cmd\/go\/internal/github.com\/goproxyio\/goproxy\/internal/g' {} +
|
||||||
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/cmd\/internal/github.com\/goproxyio\/goproxy\/internal/g' {} +
|
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/cmd\/internal/github.com\/goproxyio\/goproxy\/internal/g' {} +
|
||||||
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/internal\/singleflight/github.com\/goproxyio\/goproxy\/internal\/singleflight/g' {} +
|
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/internal\/singleflight/github.com\/goproxyio\/goproxy\/internal\/singleflight/g' {} +
|
||||||
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/internal\/testenv/github.com\/goproxyio\/goproxy\/internal\/testenv/g' {} +
|
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/internal\/testenv/github.com\/goproxyio\/goproxy\/internal\/testenv/g' {} +
|
||||||
|
|
||||||
|
if [[ "$GTGO12" = "1" ]]
|
||||||
|
then
|
||||||
|
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/internal\/goroot/github.com\/goproxyio\/goproxy\/internal\/goroot/g' {} +
|
||||||
|
find "${PKG}" -type f -name '*.go' -exec sed -i -e 's/internal\/xcoff/github.com\/goproxyio\/goproxy\/internal\/xcoff/g' {} +
|
||||||
|
fi
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1 +1,3 @@
|
||||||
module github.com/goproxyio/goproxy
|
module github.com/goproxyio/goproxy
|
||||||
|
|
||||||
|
go 1.12
|
||||||
|
|
19
main.go
19
main.go
|
@ -8,8 +8,10 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -24,6 +26,23 @@ func init() {
|
||||||
flag.StringVar(&cacheDir, "cacheDir", "", "go modules cache dir")
|
flag.StringVar(&cacheDir, "cacheDir", "", "go modules cache dir")
|
||||||
flag.StringVar(&listen, "listen", "0.0.0.0:8081", "service listen address")
|
flag.StringVar(&listen, "listen", "0.0.0.0:8081", "service listen address")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
isGitValid := checkGitVersion()
|
||||||
|
if !isGitValid {
|
||||||
|
log.Fatal("Error in git version, please check your git installed in local, must be great 2.0")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func checkGitVersion() bool {
|
||||||
|
var err error
|
||||||
|
var ret []byte
|
||||||
|
cmd := exec.Command("git", "version")
|
||||||
|
if ret, err = cmd.Output(); err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if strings.HasPrefix(string(ret), "git version 2") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
Loading…
Reference in New Issue