This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package item | |
type Item struct { | |
Price float64 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cart | |
import "customer" | |
import "item" | |
type Client struct { | |
} | |
func (c *Client) Purchase(who *customer.User, what *item.Item) { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package customer | |
import "item" | |
type User struct { | |
Name string | |
} | |
type Item => item.Item |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cart | |
type Cart struct { | |
} | |
func (c *Cart) Subtotal() float64 { | |
// calculate and return | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package store | |
import "cart" | |
type Store struct { | |
} | |
func (s *Store) RenderPage(c *cart.Cart) { | |
// Do thing with total | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package store | |
type Totaller interface { | |
Subtotal() float64 | |
} | |
type Store struct { | |
} | |
func (s *Store) RenderPage(t Totaller) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package news | |
import "store" | |
type Totaller interface { | |
Subtotal() float64 | |
} | |
type NewsfeedRenderable struct {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package news | |
type Totaller interface { | |
Subtotal() float64 | |
} | |
type NewsfeedRenderable struct {} | |
func (n *NewsfeedRenderable) RenderPage(t Totaller) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app | |
type Totaller interface { | |
Subtotal() float64 | |
} | |
type Renderable interface { | |
RenderPage(t Totaller) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"app" | |
"store" | |
) | |
func main( { | |
// ./store_main.go:9: cannot use Store literal (type *Store) as type app.Renderable in argument to app.RunApplication: | |
// *Store does not implement app.Renderable (wrong type for RenderPage method) |