ardanlabs / service

Starter-kit for writing services in Go using Kubernetes.
https://www.ardanlabs.com
Apache License 2.0
3.59k stars 649 forks source link

It is suggested to improve the naming of returned errors from the database layer #396

Closed mrbardia72 closed 4 months ago

mrbardia72 commented 5 months ago

Proposal: It is not better to write the names in one of the following ways for better readability

Like in the link below: https://github.com/ardanlabs/service/blob/master/business/domain/homebus/stores/homedb/homedb.go#L59

Line 59, which is as follows.

return fmt.Errorf("namedexeccontext: %w", err)

Convert to a format like the following examples return fmt.Errorf("named.exec.context: %w", err) return fmt.Errorf("named-exec-context: %w", err) return fmt.Errorf("named_exec_context: %w", err)

ardan-bkennedy commented 5 months ago

Not sure it really matters, I prefer things in the log be lowercase but I'm not always good with keeping that rule. Using the name of the function is easy and I think helps. In the end, you need a pattern the entire team can follow without too much trouble.