mirror of
https://github.com/Forceu/Gokapi.git
synced 2026-01-06 00:49:33 -06:00
Fixed reading terminal input on Windows, fixed upload error for Files > 20MB, fixed build tags
This commit is contained in:
1
.github/workflows/test-code.yml
vendored
1
.github/workflows/test-code.yml
vendored
@@ -13,4 +13,5 @@ jobs:
|
||||
with:
|
||||
go-version: '^1.16.4'
|
||||
- run: go test ./... --tags=test,awsmock
|
||||
- run: go clean -testcache
|
||||
- run: go test ./... --tags=test,noaws
|
||||
|
||||
@@ -12,8 +12,9 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -233,21 +234,29 @@ func askForPassword() string {
|
||||
}
|
||||
return envPassword
|
||||
}
|
||||
password1, err := terminal.ReadPassword(0)
|
||||
helper.Check(err)
|
||||
if utf8.RuneCountInString(string(password1)) < minLengthPassword {
|
||||
password1 := readPassword()
|
||||
if utf8.RuneCountInString(password1) < minLengthPassword {
|
||||
fmt.Println("\nPassword needs to be at least " + strconv.Itoa(minLengthPassword) + " characters long")
|
||||
return askForPassword()
|
||||
}
|
||||
fmt.Print("\nPassword (repeat): ")
|
||||
password2, err := terminal.ReadPassword(0)
|
||||
helper.Check(err)
|
||||
if string(password1) != string(password2) {
|
||||
password2 := readPassword()
|
||||
if password1 != password2 {
|
||||
fmt.Println("\nPasswords dont match")
|
||||
return askForPassword()
|
||||
}
|
||||
fmt.Println()
|
||||
return string(password1)
|
||||
return password1
|
||||
}
|
||||
|
||||
func readPassword() string {
|
||||
if runtime.GOOS != "windows" {
|
||||
pw, err := term.ReadPassword(0)
|
||||
if err == nil {
|
||||
return string(pw)
|
||||
}
|
||||
}
|
||||
return helper.ReadLine()
|
||||
}
|
||||
|
||||
// Asks if the server shall be bound to 127.0.0.1 or loads it from env and returns result as bool
|
||||
|
||||
@@ -7,7 +7,6 @@ Simplified OS functions
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// FolderExists returns true if a folder exists
|
||||
@@ -38,9 +37,10 @@ func CreateDir(name string) {
|
||||
|
||||
// ReadLine reads a line from the terminal and returns it as a string
|
||||
func ReadLine() string {
|
||||
reader := bufio.NewReader(os.Stdin)
|
||||
text, _ := reader.ReadString('\n')
|
||||
return strings.Replace(text, "\n", "", -1)
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
scanner.Scan()
|
||||
text := scanner.Text()
|
||||
return text
|
||||
}
|
||||
|
||||
// Check panics if error is not nil
|
||||
|
||||
@@ -75,6 +75,7 @@ func deleteTempFile(file *os.File) {
|
||||
if file == nil {
|
||||
return
|
||||
}
|
||||
file.Close()
|
||||
err := os.Remove(file.Name())
|
||||
helper.Check(err)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// +build !noaws
|
||||
// +build !awsmock
|
||||
// +build !noaws,!awsmock
|
||||
|
||||
package aws
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// +build !noaws
|
||||
// +build awsmock
|
||||
// +build !noaws,awsmock
|
||||
|
||||
package aws
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// +build noaws
|
||||
// +build !awsmock
|
||||
// +build noaws,!awsmock
|
||||
|
||||
package aws
|
||||
|
||||
|
||||
Reference in New Issue
Block a user