first commit
This commit is contained in:
commit
16f349df23
2 changed files with 27 additions and 0 deletions
3
go.mod
Normal file
3
go.mod
Normal file
|
@ -0,0 +1,3 @@
|
|||
module git.samahh.dev/sam/go-helpers
|
||||
|
||||
go 1.22.5
|
24
helpers.go
Normal file
24
helpers.go
Normal file
|
@ -0,0 +1,24 @@
|
|||
package helpers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
)
|
||||
|
||||
func Input(text string) string {
|
||||
fmt.Print(text)
|
||||
var input string
|
||||
fmt.Scanln(&input)
|
||||
return input
|
||||
}
|
||||
|
||||
func HandleError(err error) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func PassthroughError[T any](val T, err error) any {
|
||||
HandleError(err)
|
||||
return val
|
||||
}
|
Loading…
Add table
Reference in a new issue