๐Ÿ“ฆ wagoodman / go-presenter

โ˜… 0 stars โ‘‚ 1 forks ๐Ÿ‘ 0 watching โš–๏ธ Apache License 2.0
๐Ÿ“ฅ Clone https://github.com/wagoodman/go-presenter.git
HTTPS git clone https://github.com/wagoodman/go-presenter.git
SSH git clone git@github.com:wagoodman/go-presenter.git
CLI gh repo clone wagoodman/go-presenter
Alex Goodman Alex Goodman add presenter interface f9c01af 4 years ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“„ .gitignore
๐Ÿ“„ go.mod
๐Ÿ“„ LICENSE
๐Ÿ“„ presenter.go
๐Ÿ“„ README.md
๐Ÿ“„ README.md

go-presenter

This repo houses a single spot for a presenter abstraction:

type Presenter interface {
    Present(writer io.Writer) error
}

I've tended to use this abstraction in multiple projects, but the abstraction itself isn't conceptually coupled to any one project. This allows for a one-stop-shop to use this abstraction without having to redefine it for each project. Why is this abstraction helpful? This abstraction enables a few things:

  • you can output bytes without the implication that you need a copy of all of the bytes to write at any one point in time
  • separates what is being encoded from the encoding invocation (similar to json.Encoder)