use random word library
This commit is contained in:
@@ -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))])
|
||||
}
|
||||
Reference in New Issue
Block a user