jfrog / build-info-go

build-info-go is a Go library and a CLI, which allows generating build-info for a source code project.
https://www.buildinfo.org
Apache License 2.0
64 stars 37 forks source link

Remove pointer from embedded checksum struct #49

Closed Or-Geva closed 2 years ago

Or-Geva commented 2 years ago

First, most of the time, the wrapper struct, which entities.Checksum is embedded inside, is a pointer itself, so there is no real benefit for using nested pointers. Seconds, entities.Checksum fields are string, when referencing one of the fields, it looks like no nil check is required but entities.Checksum itself could be nil. This may open the door for runtime exceptions such as here https://github.com/jfrog/jfrog-cli/issues/1297.

The solution to this problem is simple, use struct instead of pointer as embedded field. Related PRs: