2025-02-02 15:11:35 +01:00

32 lines
497 B
Go

package model
import "fmt"
type PlayerID string
type Player struct {
ID PlayerID
Name string
Elo int
}
func NewPlayer(name string) Player {
return Player{
Name: name,
Elo: 1000,
}
}
func (id *PlayerID) Scan(src any) error {
switch v := src.(type) {
case int64:
*id = PlayerID(fmt.Sprintf("%d", v)) // Convert int64 to string and assign it
return nil
case string:
*id = PlayerID(v)
return nil
default:
return fmt.Errorf("unsupported type %T for PlayerID", src)
}
}