Feat: add example config
This commit is contained in:
		
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1,3 +1,4 @@ | |||||||
| .aider* | .aider* | ||||||
| golias | golias | ||||||
| store.json | store.json | ||||||
|  | config.toml | ||||||
|   | |||||||
							
								
								
									
										44
									
								
								.golangci.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								.golangci.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,44 @@ | |||||||
|  | version: "2" | ||||||
|  | run: | ||||||
|  |   concurrency: 2 | ||||||
|  |   tests: false | ||||||
|  | linters: | ||||||
|  |   default: none | ||||||
|  |   enable: | ||||||
|  |     - bodyclose | ||||||
|  |     - errcheck | ||||||
|  |     - fatcontext | ||||||
|  |     - govet | ||||||
|  |     - ineffassign | ||||||
|  |     - noctx | ||||||
|  |     - perfsprint | ||||||
|  |     - prealloc | ||||||
|  |     - staticcheck | ||||||
|  |     - unused | ||||||
|  |   settings: | ||||||
|  |     funlen: | ||||||
|  |       lines: 80 | ||||||
|  |       statements: 50 | ||||||
|  |     lll: | ||||||
|  |       line-length: 80 | ||||||
|  |   exclusions: | ||||||
|  |     generated: lax | ||||||
|  |     presets: | ||||||
|  |       - comments | ||||||
|  |       - common-false-positives | ||||||
|  |       - legacy | ||||||
|  |       - std-error-handling | ||||||
|  |     paths: | ||||||
|  |       - third_party$ | ||||||
|  |       - builtin$ | ||||||
|  |       - examples$ | ||||||
|  | issues: | ||||||
|  |   max-issues-per-linter: 0 | ||||||
|  |   max-same-issues: 0 | ||||||
|  | formatters: | ||||||
|  |   exclusions: | ||||||
|  |     generated: lax | ||||||
|  |     paths: | ||||||
|  |       - third_party$ | ||||||
|  |       - builtin$ | ||||||
|  |       - examples$ | ||||||
							
								
								
									
										11
									
								
								config.example.toml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								config.example.toml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | |||||||
|  | BASE_URL = "https://localhost:3000" | ||||||
|  | SESSION_LIFETIME_SECONDS = 30000 | ||||||
|  | COOKIE_SECRET = "test" | ||||||
|  |  | ||||||
|  | [SERVICE] | ||||||
|  | HOST = "localhost" | ||||||
|  | PORT = "3000" | ||||||
|  |  | ||||||
|  | [LLM] | ||||||
|  | TOKEN = "" | ||||||
|  | URL = "https://api.deepseek.com/beta" | ||||||
| @@ -10,7 +10,6 @@ type Config struct { | |||||||
| 	ServerConfig    ServerConfig `toml:"SERVICE"` | 	ServerConfig    ServerConfig `toml:"SERVICE"` | ||||||
| 	BaseURL         string       `toml:"BASE_URL"` | 	BaseURL         string       `toml:"BASE_URL"` | ||||||
| 	SessionLifetime int          `toml:"SESSION_LIFETIME_SECONDS"` | 	SessionLifetime int          `toml:"SESSION_LIFETIME_SECONDS"` | ||||||
| 	DBURI           string       `toml:"DBURI"` |  | ||||||
| 	CookieSecret    string       `toml:"COOKIE_SECRET"` | 	CookieSecret    string       `toml:"COOKIE_SECRET"` | ||||||
| 	LLMConfig       LLMConfig    `toml:"LLM"` | 	LLMConfig       LLMConfig    `toml:"LLM"` | ||||||
| } | } | ||||||
|   | |||||||
| @@ -56,10 +56,6 @@ func removeRoom(roomID string) { | |||||||
| } | } | ||||||
|  |  | ||||||
| // context | // context | ||||||
| func getRoomIDFromCtx(ctx context.Context) string { |  | ||||||
| 	id, _ := ctx.Value(models.CtxRoomIDKey).(string) |  | ||||||
| 	return id |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func getStateByCtx(ctx context.Context) (*models.UserState, error) { | func getStateByCtx(ctx context.Context) (*models.UserState, error) { | ||||||
| 	username, ok := ctx.Value(models.CtxUsernameKey).(string) | 	username, ok := ctx.Value(models.CtxUsernameKey).(string) | ||||||
| @@ -74,15 +70,6 @@ func getStateByCtx(ctx context.Context) (*models.UserState, error) { | |||||||
| 	return us, nil | 	return us, nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func saveStateByCtx(ctx context.Context, state *models.UserState) error { |  | ||||||
| 	username, ok := ctx.Value(models.CtxUsernameKey).(string) |  | ||||||
| 	if !ok { |  | ||||||
| 		log.Debug("no username in ctx") |  | ||||||
| 		return errors.New("no username in ctx") |  | ||||||
| 	} |  | ||||||
| 	return saveState(username, state) |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func saveFullInfo(fi *models.FullInfo) error { | func saveFullInfo(fi *models.FullInfo) error { | ||||||
| 	// INFO: unfortunately working no transactions; so case are possible where first object is updated but the second is not | 	// INFO: unfortunately working no transactions; so case are possible where first object is updated but the second is not | ||||||
| 	if err := saveState(fi.State.Username, fi.State); err != nil { | 	if err := saveState(fi.State.Username, fi.State); err != nil { | ||||||
|   | |||||||
| @@ -1,12 +1,10 @@ | |||||||
| package handlers | package handlers | ||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"context" |  | ||||||
| 	"crypto/hmac" | 	"crypto/hmac" | ||||||
| 	"crypto/sha256" | 	"crypto/sha256" | ||||||
| 	"encoding/base64" | 	"encoding/base64" | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"errors" |  | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"golias/models" | 	"golias/models" | ||||||
| 	"golias/utils" | 	"golias/utils" | ||||||
| @@ -178,11 +176,12 @@ func cacheSetSession(key string, session *models.Session) error { | |||||||
| 	return nil | 	return nil | ||||||
| } | } | ||||||
|  |  | ||||||
| func updateRoomInSession(ctx context.Context, roomID string) (context.Context, error) { | // unused | ||||||
| 	s, ok := ctx.Value(models.CtxSessionKey).(*models.Session) | // func updateRoomInSession(ctx context.Context, roomID string) (context.Context, error) { | ||||||
| 	if !ok { | // 	s, ok := ctx.Value(models.CtxSessionKey).(*models.Session) | ||||||
| 		return context.TODO(), errors.New("failed to extract session from ctx") | // 	if !ok { | ||||||
| 	} | // 		return context.TODO(), errors.New("failed to extract session from ctx") | ||||||
| 	s.CurrentRoom = roomID | // 	} | ||||||
| 	return context.WithValue(ctx, "session", s), nil | // 	s.CurrentRoom = roomID | ||||||
| } | // 	return context.WithValue(ctx, "session", s), nil | ||||||
|  | // } | ||||||
|   | |||||||
| @@ -29,34 +29,6 @@ func init() { | |||||||
| 	// go Notifier.Listen() | 	// go Notifier.Listen() | ||||||
| } | } | ||||||
|  |  | ||||||
| var roundWords = map[string]string{ |  | ||||||
| 	"hamster":    "blue", |  | ||||||
| 	"child":      "red", |  | ||||||
| 	"wheel":      "white", |  | ||||||
| 	"condition":  "black", |  | ||||||
| 	"test":       "white", |  | ||||||
| 	"ball":       "blue", |  | ||||||
| 	"violin":     "red", |  | ||||||
| 	"rat":        "white", |  | ||||||
| 	"perplexity": "blue", |  | ||||||
| 	"notion":     "red", |  | ||||||
| 	"guitar":     "blue", |  | ||||||
| 	"ocean":      "blue", |  | ||||||
| 	"moon":       "blue", |  | ||||||
| 	"coffee":     "blue", |  | ||||||
| 	"mountain":   "blue", |  | ||||||
| 	"book":       "blue", |  | ||||||
| 	"camera":     "blue", |  | ||||||
| 	"apple":      "red", |  | ||||||
| 	"fire":       "red", |  | ||||||
| 	"rose":       "red", |  | ||||||
| 	"sun":        "red", |  | ||||||
| 	"cherry":     "red", |  | ||||||
| 	"heart":      "red", |  | ||||||
| 	"tomato":     "red", |  | ||||||
| 	"cloud":      "white", |  | ||||||
| } |  | ||||||
|  |  | ||||||
| func HandlePing(w http.ResponseWriter, r *http.Request) { | func HandlePing(w http.ResponseWriter, r *http.Request) { | ||||||
| 	w.Write([]byte("pong")) | 	w.Write([]byte("pong")) | ||||||
| } | } | ||||||
|   | |||||||
| @@ -236,6 +236,7 @@ func (rr *RoomReq) CreateRoom(creator string) *Room { | |||||||
| 		CreatedAt:   time.Now(), | 		CreatedAt:   time.Now(), | ||||||
| 		PlayerList:  []string{creator}, | 		PlayerList:  []string{creator}, | ||||||
| 		CreatorName: creator, | 		CreatorName: creator, | ||||||
|  | 		BotMap:      make(map[string]BotPlayer), | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder