A Go module for parsing and working with chess games in PGN format
go get github.com/Shobhit-Nagpal/pgn package main
import (
"fmt"
"github.com/Shobhit-Nagpal/pgn"
)
func main() {
// Parse a PGN string
gameStr := `[Event "F/S Return Match"]
[Site "Belgrade, Serbia JUG"]
[Date "1992.11.04"]
[Round "29"]
[White "Fischer, Robert J."]
[Black "Spassky, Boris V."]
[Result "1/2-1/2"]
1. e4 e5 2. Nf3 Nc6 3. Bb5 1/2-1/2`
game, err := pgn.New(gameStr)
if err != nil {
panic(err)
}
// Access game information
fmt.Println("Event:", game.Event())
fmt.Println("White Player:", game.White())
fmt.Println("Black Player:", game.Black())
fmt.Println("Result:", game.Result())
}