mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 09:00:20 +08:00
e0454138e0
* update goctl to go 1.16 for io/fs usage * feat: support pg serial type for auto_increment (#1563) * add correct example for pg's url * 🐞 fix: merge * 🐞 fix: pg default port * ✨ feat: support serial type Co-authored-by: kurimi1 <d0n41df@gmail.com> * chore: format code Co-authored-by: toutou_o <33993460+kurimi1@users.noreply.github.com> Co-authored-by: kurimi1 <d0n41df@gmail.com>
45 lines
810 B
Go
45 lines
810 B
Go
package migrate
|
|
|
|
import (
|
|
"net/url"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/zeromicro/go-zero/core/stringx"
|
|
"github.com/zeromicro/go-zero/tools/goctl/rpc/execx"
|
|
)
|
|
|
|
var (
|
|
defaultProxy = "https://goproxy.cn"
|
|
defaultProxies = []string{defaultProxy}
|
|
)
|
|
|
|
func goProxy() []string {
|
|
wd, err := os.Getwd()
|
|
if err != nil {
|
|
return defaultProxies
|
|
}
|
|
|
|
proxy, err := execx.Run("go env GOPROXY", wd)
|
|
if err != nil {
|
|
return defaultProxies
|
|
}
|
|
list := strings.FieldsFunc(proxy, func(r rune) bool {
|
|
return r == '|' || r == ','
|
|
})
|
|
var ret []string
|
|
for _, item := range list {
|
|
if len(item) == 0 {
|
|
continue
|
|
}
|
|
_, err = url.Parse(item)
|
|
if err == nil && !stringx.Contains(ret, item) {
|
|
ret = append(ret, item)
|
|
}
|
|
}
|
|
if !stringx.Contains(ret, defaultProxy) {
|
|
ret = append(ret, defaultProxy)
|
|
}
|
|
return ret
|
|
}
|