gobuffalo / envy

Envy makes working with ENV variables in Go trivial.
MIT License
156 stars 21 forks source link

envy is trying to load .env files even when not asked to #30

Closed fazalmajid closed 5 years ago

fazalmajid commented 5 years ago

Why is this module I had never heard about spewing on the output of Hugo, among others?

ecthelion ~/go>./bin/hugo --help
[ENVY] unable to load env file(s) on init: open .env: no such file or directory
hugo is the main command, used to build your Hugo site.

Hugo is a Fast and Flexible Static Site Generator
built with love by spf13 and friends in Go.

Complete documentation is available at http://gohugo.io/.
...

README.md claims "By default, no env files will be loaded." but envy.go is clearly trying to do so in init(), and what's worse, outputting an unsolicited error message on stderr.

Here is a minimal reproduction case:

ecthelion ~/hugo/fts5index>cat envy.go 
package main

import (
    "fmt"
    "github.com/gobuffalo/envy"
)

func main() {
    fmt.Println(envy.GO111MODULE)
}
ecthelion ~/hugo/fts5index>go run envy.go
[ENVY] unable to load env file(s) on init: open .env: no such file or directory
GO111MODULE
markbates commented 5 years ago

Agreed. @mclark4386 can you please revert that change and release a new version?

fazalmajid commented 5 years ago

Thanks. Is there any reason why Hugo should not switch from markbates/inflect to gobuffalo/flect?

https://github.com/gohugoio/hugo/pull/6323

fazalmajid commented 5 years ago

I guess this would be a reason, flect behaves differently from inflect:

https://travis-ci.org/gohugoio/hugo/jobs/583939617

ecthelion ~/hugo/fts5index>cat envy.go;go run envy.go
package main

import (
    "fmt"
    "github.com/gobuffalo/flect"
    "github.com/markbates/inflect"
)

func main() {
    fmt.Println(inflect.Humanize("MyCamel"))
    fmt.Println(flect.Humanize("MyCamel"))
}
My camel
My Camel