// ProtoDiff generates an indented summary of the diff between two protos'
// YAML representations. See ProtoToYAML for documentation on rewrites.
func ProtoDiff(a, b protoutil.Message, args DiffArgs, rewrites func(interface{})) string {
toYAML := func(m protoutil.Message) string {
if m == nil {
return ""
}
str, err := ProtoToYAML(m, false /* emitDefaults */, rewrites)
- good architecture = allow changes w/ flexibility + delay decision
- Entities: pure; small sets of critical business rules. Should be most independent & reusable. Can be an object with methods or data structures & functions
- Use case: not as pure; is an object. contains data elements & operations.
- Entities are lower level than (don’t depend on) use cases since use cases are closer to inputs/outputs.
- Entities & use cases are 2 layers
If you have several tools that are very closely related, you can make them easier to use, discover, and distribute by combining them into a single tool (and a single executable binary artifact).
If you’ve got a tool that’s sufficiently complex, you can reduce its complexity by making a set of subcommands. This is also useful for sharing stuff—global flags, help text, configuration, storage mechanisms.The above guidance doesn’t help you to decide when something is unrelated and should be separated, BTW.
It is worth comparing this advice to the Command Pattern from the “Gang of Four” “Design Patterns” book, where you encapsulate an an action or a request as an object that can be parameterized. Usually, in the Command Design Pattern the invoker doesn’t know anything about the implementation details of the command or it’s receiver, it just knows the command interface and its only responsibility is to invoke the command and optionally do some bookkeeping of what commands are possible and/or valid. There are
| package main | |
| import ( | |
| "fmt" | |
| "log" | |
| "context" | |
| "cloud.google.com/go/storage" |
| package main | |
| import ( | |
| "fmt" | |
| "io/ioutil" | |
| "log" | |
| "context" | |
| "cloud.google.com/go/storage" |
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| var ( | |
| ones = []string{ | |
| "zero", "one", "two", "three", "four", | |
| "five", "six", "seven", "eight", "nine", |
Random AST and SSA Helpers
- https://github.com/Antonboom/testifylint/blob/master/internal/checkers/helpers_context.go#L28
- https://github.com/go-courier/packagesx/blob/master/package.go
- https://github.com/palantir/pkg/blob/bb8ac9f7716d89cb3cd0ac34c9315b05ea91e7da/pkgpath/packages.go#L21
- https://gist.github.com/ncdc/fef1099f54a655f8fb11daf86f7868b8
- https://gist.github.com/ncdc/fef1099f54a655f8fb11daf86f7868b8
- https://magodo.github.io/go-ast-tips/
- https://blog.stackademic.com/the-anatomy-of-go-code-dissecting-with-the-go-ast-package-325a43a1618c
- https://github.com/ace-design/anaximander-microservices/blob/master/probes/Http/probe.go
| package main | |
| import ( | |
| "fmt" | |
| "go/ast" | |
| "go/parser" | |
| "go/token" | |
| ) | |
| func main() { |