use random word library
This commit is contained in:
parent
ad286d745f
commit
a1d2669dad
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"petname"
|
||||
]
|
||||
}
|
@ -1,2 +1,3 @@
|
||||
# hangman
|
||||
|
||||
- [ ] clean up https://gitea.elara.ws/Hazel/go-words as actual library
|
2
go.mod
2
go.mod
@ -3,6 +3,8 @@ module gitea.elara.ws/Hazel/hangman
|
||||
go 1.24.2
|
||||
|
||||
require (
|
||||
gitea.elara.ws/Hazel/go-words v0.0.0-20250701093631-6125867cea5a // indirect
|
||||
gitea.elara.ws/Hazel/words v1.0.5 // indirect
|
||||
github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 // indirect
|
||||
github.com/labstack/echo/v4 v4.13.4 // indirect
|
||||
github.com/labstack/gommon v0.4.2 // indirect
|
||||
|
6
go.sum
6
go.sum
@ -1,3 +1,9 @@
|
||||
gitea.elara.ws/Hazel/go-words v0.0.0-20250701093631-6125867cea5a h1:E5BgJBsBKL1MNW1W6HK69XYXvDKtYLfRezl1nh27B5g=
|
||||
gitea.elara.ws/Hazel/go-words v0.0.0-20250701093631-6125867cea5a/go.mod h1:8vVkpfa+5Xcte2f7YaH6ao8kVZlbz1ErCVGqNanaNLA=
|
||||
gitea.elara.ws/Hazel/words v1.0.4 h1:pc7RZ0gNYMZ/zeYmY7FZrscZZOO4TEQt5d6SsXLe4zc=
|
||||
gitea.elara.ws/Hazel/words v1.0.4/go.mod h1:IwQ+eZpY2Kr02RPYpyFDjHNJPPbsf1NOvgc4ZMeg2zg=
|
||||
gitea.elara.ws/Hazel/words v1.0.5 h1:FjpQezXDPxgNing/DAMJStLT3TC7/dxvCQj3Cg3AJB4=
|
||||
gitea.elara.ws/Hazel/words v1.0.5/go.mod h1:IwQ+eZpY2Kr02RPYpyFDjHNJPPbsf1NOvgc4ZMeg2zg=
|
||||
github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0 h1:aYo8nnk3ojoQkP5iErif5Xxv0Mo0Ga/FR5+ffl/7+Nk=
|
||||
github.com/dustinkirkland/golang-petname v0.0.0-20240428194347-eebcea082ee0/go.mod h1:8AuBTZBRSFqEYBPYULd+NN474/zZBLP+6WeT5S9xlAc=
|
||||
github.com/labstack/echo/v4 v4.13.4 h1:oTZZW+T3s9gAu5L8vmzihV7/lkXGZuITzTQkTEhcXEA=
|
||||
|
@ -4,11 +4,11 @@ import (
|
||||
"net/http"
|
||||
|
||||
"gitea.elara.ws/Hazel/hangman/internal/game"
|
||||
"gitea.elara.ws/Hazel/hangman/internal/words"
|
||||
"gitea.elara.ws/Hazel/words"
|
||||
"github.com/labstack/echo/v4"
|
||||
)
|
||||
|
||||
func CreateSession(c echo.Context) error {
|
||||
s := game.NewSession(words.GetRandomWord())
|
||||
s := game.NewSession(words.Words.GetRandomWord())
|
||||
return c.JSON(http.StatusOK, s)
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,11 +0,0 @@
|
||||
package words
|
||||
|
||||
import (
|
||||
"math/rand/v2"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func GetRandomWord() string {
|
||||
// https://stackoverflow.com/a/22876612/16804841
|
||||
return strings.ToLower(Words[rand.IntN(len(Words))])
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user