diff --git a/factorial/main.go b/factorial/main.go index 27f1bcb..9a1c918 100644 --- a/factorial/main.go +++ b/factorial/main.go @@ -7,7 +7,6 @@ import ( ) var numFinal int = 1 -var multiplicado int = 1 func main() { if len(os.Args) < 2 || len(os.Args) > 2 { @@ -22,8 +21,6 @@ func main() { fmt.Println(err) } - // TODO: Fix this garbage - for i := 1; i <= numFactorial; i++ { numFinal = numFinal * i } diff --git a/golangr/file-reader/main.go b/golangr/file-reader/main.go index 2ec690d..03475fd 100644 --- a/golangr/file-reader/main.go +++ b/golangr/file-reader/main.go @@ -5,6 +5,8 @@ import ( "fmt" "math/rand" "os" + "strconv" + "strings" //"strconv" ) @@ -21,8 +23,9 @@ var guessLetter rune func scanLine() (line string) { in := bufio.NewReader(os.Stdin) - line, err := in.ReadString('\n') + lineNew, err := in.ReadString('\n') catchErr(err) + line = strings.Trim(lineNew, "\n") return line } @@ -37,7 +40,25 @@ func main() { // catchErr(err) player.name = scanLine() - fmt.Println(player.name) + for { + fmt.Printf("How many lives would you like to have?\nLives: ") + stringLives := scanLine() + //TODO: fix this garbage + intLives, err := strconv.Atoi(stringLives) + catchErr(err) + player.lives = uint8(intLives) + + fmt.Printf("Name: %v\n", player.name) + fmt.Printf("Lives: %v\n", player.lives) + + fmt.Printf("Proceed? [y/n] ") + var choice string + _, err = fmt.Scanln(&choice) + catchErr(err) + if choice == "y" { + break + } + } filePath := os.Args[1] randWord := getWord(filePath) diff --git a/golangr/range/go.mod b/golangr/range/go.mod index ff2ac0c..cd3b989 100644 --- a/golangr/range/go.mod +++ b/golangr/range/go.mod @@ -2,4 +2,4 @@ module range go 1.21.6 -require git.bulgariu.xyz/raul/min-max-array v0.0.0-20240130184833-a25a49c11fc5 +require git.bulgariu.xyz/raul/min-max-array v0.0.0-20240131105739-41c2fcc5af70 diff --git a/golangr/range/go.sum b/golangr/range/go.sum index 22a3196..864245c 100644 --- a/golangr/range/go.sum +++ b/golangr/range/go.sum @@ -1,2 +1,4 @@ git.bulgariu.xyz/raul/min-max-array v0.0.0-20240130184833-a25a49c11fc5 h1:+4SdxwW8y687yR/ctDOdmcuJGxcI0oLPiNOrg28zSIo= git.bulgariu.xyz/raul/min-max-array v0.0.0-20240130184833-a25a49c11fc5/go.mod h1:PdMyknNgNZYKg03bYhSc4aaSA/P3yScGPfxC4z+ju0c= +git.bulgariu.xyz/raul/min-max-array v0.0.0-20240131105739-41c2fcc5af70 h1:q/uQwkakAZnaus16KHG6UkBFZzNaMbjY3SCZjh0Pytk= +git.bulgariu.xyz/raul/min-max-array v0.0.0-20240131105739-41c2fcc5af70/go.mod h1:PdMyknNgNZYKg03bYhSc4aaSA/P3yScGPfxC4z+ju0c= diff --git a/golangr/range/main.go b/golangr/range/main.go index e4f8425..84b0c1d 100644 --- a/golangr/range/main.go +++ b/golangr/range/main.go @@ -8,7 +8,6 @@ import ( ) // https://golangr.com/range -// TODO: Create something similar to the array exercise but cleaner and better var notas []float64 var choice int8 @@ -93,6 +92,8 @@ func getMinMax() { // Me finally getting to make use of my first library :) minNota := minmax.Min(notas) maxNota := minmax.Max(notas) + // minNota := Min(notas) + // maxNota := Max(notas) fmt.Printf("\n-----------------------------------------------") fmt.Printf("\nLargest grade: %v\n", maxNota) fmt.Printf("Smallest grade: %v\n", minNota) diff --git a/yes-clone/go.mod b/yes-clone/go.mod new file mode 100644 index 0000000..40b871e --- /dev/null +++ b/yes-clone/go.mod @@ -0,0 +1,10 @@ +module yesClone + +go 1.21.6 + +require ( + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/urfave/cli/v2 v2.27.1 // indirect + github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect +) diff --git a/yes-clone/go.sum b/yes-clone/go.sum new file mode 100644 index 0000000..31517c0 --- /dev/null +++ b/yes-clone/go.sum @@ -0,0 +1,8 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho= +github.com/urfave/cli/v2 v2.27.1/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=