Skip to content

Instantly share code, notes, and snippets.

@punmechanic
Last active October 3, 2021 16:12
Show Gist options
  • Save punmechanic/5b3f19e931524e137b68db9c7d555877 to your computer and use it in GitHub Desktop.
Save punmechanic/5b3f19e931524e137b68db9c7d555877 to your computer and use it in GitHub Desktop.
package cli
type awsConfig struct {
ini *ini.File
Path string
}
func (a* awsConfig) Append(entry AWSCliEntry) {
// Runtime error - a.ini is nil
a.ini.Section(entry.profileName)
// Because we have a pointer in our struct (because the ini library only returns pointers to ini.File),
// We need to add additional book-keeping in any function that accesses that field, or we need some initialisation logic,
// which means we can't use the zero value form of awsConfig below, and none of this is obvious to the caller.
// Alternatively, we can dereference the pointer, however this also does not work in this case because ini.File contains a map,
// so that just causes a runtime error elsewhere.
// in short i really don't like the ini library lol
}
func a() {
var cfg awsConfig
cfg.Append(AWSCliEntry{profileName: "profile"})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment