Skip to content

Commit

Permalink
Fix version to the latest at the time
Browse files Browse the repository at this point in the history
Signed-off-by: Ulysses Souza <[email protected]>
  • Loading branch information
ulyssessouza authored and Ulysses Souza committed Nov 11, 2024
1 parent 185b695 commit 07ae1a0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ clean:
@rm -rf gen

setup:
go install gotest.tools/gotestsum@v1.11.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install gotest.tools/gotestsum@v1.12.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.0

vendor:
go mod vendor
2 changes: 1 addition & 1 deletion compat/joho/godotenv/autoload/autoload.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import (
)

func init() {
envlang.Load()
envlang.Load() //nolint:errcheck // This is not necessary to check
}
10 changes: 5 additions & 5 deletions compat/joho/godotenv/facade.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package compat_env
package godotenv

import (
"bytes"
Expand All @@ -11,6 +11,7 @@ import (
"github.com/ulyssessouza/envlang/dao"
)

//nolint:gocognit
func GetEnvFromFile(currentEnv map[string]string, filenames []string) (map[string]string, error) {
envMap := make(map[string]string)

Expand All @@ -23,7 +24,7 @@ func GetEnvFromFile(currentEnv map[string]string, filenames []string) (map[strin

s, err := os.Stat(dotEnvFile)
if os.IsNotExist(err) {
return envMap, fmt.Errorf("Couldn't find env file: %s", dotEnvFile)
return envMap, fmt.Errorf("couldn't find env file: %s", dotEnvFile)
}
if err != nil {
return envMap, err
Expand All @@ -38,7 +39,7 @@ func GetEnvFromFile(currentEnv map[string]string, filenames []string) (map[strin

b, err := os.ReadFile(dotEnvFile)
if os.IsNotExist(err) {
return nil, fmt.Errorf("Couldn't read env file: %s", dotEnvFile)
return nil, fmt.Errorf("couldn't read env file: %s", dotEnvFile)
}
if err != nil {
return envMap, err
Expand All @@ -63,8 +64,6 @@ func GetEnvFromFile(currentEnv map[string]string, filenames []string) (map[strin
return envMap, nil
}

var utf8BOM = []byte("\uFEFF")

// Parse reads an env file from io.Reader, returning a map of keys and values.
func Parse(r io.Reader) (map[string]string, error) {
return ParseWithLookup(r, nil)
Expand All @@ -79,6 +78,7 @@ func ParseWithLookup(r io.Reader, lookupFn dao.LookupFn) (map[string]string, err

// seek past the UTF-8 BOM if it exists (particularly on Windows, some
// editors tend to add it, and it'll cause parsing to fail)
utf8BOM := []byte("\uFEFF")
data = bytes.TrimPrefix(data, utf8BOM)

return UnmarshalBytesWithLookup(data, lookupFn)
Expand Down
4 changes: 2 additions & 2 deletions compat/joho/godotenv/facade_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package compat_env
package godotenv

import (
"os"
Expand Down Expand Up @@ -39,7 +39,7 @@ func TestEnvVariablePrecedence(t *testing.T) {
for _, test := range testcases {
t.Run(test.name, func(t *testing.T) {
wd := t.TempDir()
err := os.WriteFile(filepath.Join(wd, ".env"), []byte(test.dotEnv), 0o700)
err := os.WriteFile(filepath.Join(wd, ".env"), []byte(test.dotEnv), 0o600)
assert.NilError(t, err)

envMap, err := GetEnvFromFile(env2Map(test.osEnv), []string{filepath.Join(wd, ".env")})
Expand Down

0 comments on commit 07ae1a0

Please sign in to comment.