Skip to content

Instantly share code, notes, and snippets.

Created Jul 20, 2019
What would you like to do?
package main
import (
func main() {
b := NewBoard()
type board struct {
Squares []*square
type square struct {
current *piece
func (s *square) addTo(buffer *bytes.Buffer) {
type piece struct {
name string
func (p *piece) addTo(buffer *bytes.Buffer) {
func NewSquare(piece *piece) *square {
return &square{
current: piece,
}//código omitido pra ficar legal no slide
func NewPiece(name string) *piece {
return &piece{
name: name,
}//código omitido pra ficar legal no slide
func NewBoard() *board {
p1 := NewPiece("king")
p2 := NewPiece("queen")
return &board{
Squares: []*square{NewSquare(p1), NewSquare(p2)},
}//código omitido pra ficar legal no slide
func (b *board) BoardRepresentation() string {
var buffer = &bytes.Buffer{}
for _, s := range b.Squares {
return buffer.String()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment