learned I didn't need git for external modules and different folders can have different mains

This commit is contained in:
2024-02-03 11:00:34 -05:00
parent 943191e9dd
commit 19b1581f10
37 changed files with 439 additions and 16 deletions

38
pkg/keyboard/keyboard.go Normal file
View File

@ -0,0 +1,38 @@
// Package keyboard reads user input from the keyboard.
package keyboard
import (
"bufio"
"os"
"strconv"
"strings"
)
// GetString reads a string from the keyboard.
// It returns the string read and any error encountered.
func GetString() (string, error) {
reader := bufio.NewReader(os.Stdin)
input, err := reader.ReadString('\n')
if err != nil {
return "", err
}
return input, nil
}
// GetFloat reads a floating-point number from the keyboard.
// It returns the number read and any error encountered.
func GetFloat() (float64, error) {
input, err := GetString()
if err != nil {
return 0, err
}
input = strings.TrimSpace(input)
number, err := strconv.ParseFloat(input, 64)
if err != nil {
return 0, err
}
return number, nil
}