https://github.com/philpennock/api_demo
Simple demo of API construction in Golang, to make callers init structs more safely
https://github.com/philpennock/api_demo
Last synced: 3 months ago
JSON representation
Simple demo of API construction in Golang, to make callers init structs more safely
- Host: GitHub
- URL: https://github.com/philpennock/api_demo
- Owner: philpennock
- Created: 2014-09-14T01:40:13.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2020-06-14T08:52:30.000Z (over 5 years ago)
- Last Synced: 2025-01-24T17:18:11.849Z (9 months ago)
- Language: Go
- Size: 1000 Bytes
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
API Demo
========This is a very simple demonstration of Golang library coding style which
prevents the caller from using unnamed struct initialization. Doing this
ensures that new fields can safely be added to the struct without breaking
backwards compatibility.Use `go run main.go` to see some output.
I've tried exploring various types, interfaces, fmt.Format and more, to try
to automatically hide the filtering field from `fmt.Printf` with `%#v` but to
no avail. I ended up going for a very short name which idiomatically conveys
"unused" to hint at what's going on; could change the type away from
`struct{}` to `int` to shorten the `%#v` output even more.