Skip to content

Commit

Permalink
fix 2nd scanf skipping user input
Browse files Browse the repository at this point in the history
  • Loading branch information
algo7 committed May 5, 2022
1 parent 15c8364 commit 8f49de2
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Binary file modified builds/setup-darwin-amd64.bin
Binary file not shown.
Binary file modified builds/setup-linux-amd64.bin
Binary file not shown.
Binary file modified builds/setup-windows-amd64.exe
Binary file not shown.
10 changes: 6 additions & 4 deletions setup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,18 @@ func main() {
// Print the message
fmt.Println("7. Reviews Directory created:", reviewsDirFullPath)

// Ask for user input
// Notify the user that the setup has been completed
fmt.Println("Setup Completed. Please place the source files in the source directory and restart the program.")

fmt.Scanln("Press Any Key to Exit...")
}

func userInputs(path string) error {

// Get scrap mode
fmt.Println("Enter the scrap mode (RESTO or HOTEL):")
var mode string
_, err := fmt.Scanf("%s", &mode)
_, err := fmt.Scanf("%s\n", &mode)

// Input validation
if err != nil || (mode != "HOTEL" && mode != "RESTO") {
Expand All @@ -149,7 +151,7 @@ func userInputs(path string) error {
// Get concurrency value
fmt.Println("Enter the concurrency value (ex: 10):")
var i int
_, err = fmt.Scanf("%d", &i)
_, err = fmt.Scanf("%d\n", &i)

// Input validation
if err != nil {
Expand Down Expand Up @@ -426,7 +428,7 @@ func dockerComposeRun(path string) error {
func errorHandler(err error) {
if err != nil {
fmt.Println(err)
fmt.Println("Press Any Key to Exit")
fmt.Println("Press Any Key to Exit...")
fmt.Scanln()
os.Exit(0)
}
Expand Down

0 comments on commit 8f49de2

Please sign in to comment.