Explorar el Código

Merge pull request #26 from dandyhuang/upstream_main

fix: windows support qrcode
main
ztino hace 4 años
cometido por GitHub
padre
commit
b4d7a11e16
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 4AEE18F83AFDEB23
  1. 38
      common/lib.go

38
common/lib.go

@ -46,7 +46,7 @@ func Utf8ToGbk(s []byte) ([]byte, error) {
}
func NewRandStr(length int) string {
s:=[]string{
s := []string{
"a", "b", "c", "d", "e", "f",
"g", "h", "i", "j", "k", "l",
"m", "n", "o", "p", "q", "r",
@ -57,20 +57,20 @@ func NewRandStr(length int) string {
"Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z",
}
str:=""
for i:=1;i<=length;i++ {
str := ""
for i := 1; i <= length; i++ {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
str+=s[r.Intn(len(s)-1)]
str += s[r.Intn(len(s)-1)]
}
return str
}
func Substr(s string,start,end int) string {
strRune:=[]rune(s)
if start==-1 {
func Substr(s string, start, end int) string {
strRune := []rune(s)
if start == -1 {
return string(strRune[:end])
}
if end==-1 {
if end == -1 {
return string(strRune[start:])
}
return string(strRune[start:end])
@ -95,17 +95,17 @@ func Exists(path string) bool {
return true
}
func OpenImage(file string) {
if runtime.GOOS=="windows" {
cmd:=exec.Command("start",file)
_=cmd.Start()
}else{
if runtime.GOOS=="linux" {
cmd:=exec.Command("eog",file)
_=cmd.Start()
}else{
cmd:=exec.Command("open",file)
_=cmd.Start()
func OpenImage(file string) {
if runtime.GOOS == "windows" {
cmd := exec.Command("cmd", "/k", "start", file)
_ = cmd.Start()
} else {
if runtime.GOOS == "linux" {
cmd := exec.Command("eog", file)
_ = cmd.Start()
} else {
cmd := exec.Command("open", file)
_ = cmd.Start()
}
}
}

Cargando…
Cancelar
Guardar