Skip to content
This repository was archived by the owner on Jan 12, 2022. It is now read-only.

Commit 29b5be9

Browse files
committed
Rename and implement int-able without quotes
1 parent d6ee687 commit 29b5be9

File tree

6 files changed

+22
-13
lines changed

6 files changed

+22
-13
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# GoDotEnv [![Build Status](https://travis-ci.org/joho/godotenv.svg?branch=master)](https://travis-ci.org/joho/godotenv) [![Build status](https://ci.appveyor.com/api/projects/status/9v40vnfvvgde64u4?svg=true)](https://ci.appveyor.com/project/joho/godotenv) [![Go Report Card](https://goreportcard.com/badge/github.com/joho/godotenv)](https://goreportcard.com/report/github.com/joho/godotenv)
1+
# GoDotEnv [![Build Status](https://travis-ci.org/mniak/godotenv.svg?branch=master)](https://travis-ci.org/mniak/godotenv) [![Build status](https://ci.appveyor.com/api/projects/status/9v40vnfvvgde64u4?svg=true)](https://ci.appveyor.com/project/mniak/godotenv) [![Go Report Card](https://goreportcard.com/badge/github.com/mniak/godotenv)](https://goreportcard.com/report/github.com/mniak/godotenv)
22

33
A Go (golang) port of the Ruby dotenv project (which loads env vars from a .env file)
44

@@ -17,12 +17,12 @@ There is test coverage and CI for both linuxish and windows environments, but I
1717
As a library
1818

1919
```shell
20-
go get github.com/joho/godotenv
20+
go get github.com/mniak/godotenv
2121
```
2222

2323
or if you want to use it as a bin command
2424
```shell
25-
go get github.com/joho/godotenv/cmd/godotenv
25+
go get github.com/mniak/godotenv/cmd/godotenv
2626
```
2727

2828
## Usage
@@ -40,7 +40,7 @@ Then in your Go app you can do something like
4040
package main
4141

4242
import (
43-
"github.com/joho/godotenv"
43+
"github.com/mniak/godotenv"
4444
"log"
4545
"os"
4646
)
@@ -61,7 +61,7 @@ func main() {
6161
If you're even lazier than that, you can just take advantage of the autoload package which will read in `.env` on import
6262

6363
```go
64-
import _ "github.com/joho/godotenv/autoload"
64+
import _ "github.com/mniak/godotenv/autoload"
6565
```
6666

6767
While `.env` in the project root is the default, you don't have to be constrained, both examples below are 100% legit
@@ -177,11 +177,11 @@ Contributions are most welcome! The parser itself is pretty stupidly naive and I
177177

178178
Releases should follow [Semver](http://semver.org/) though the first couple of releases are `v1` and `v1.1`.
179179

180-
Use [annotated tags for all releases](https://github.com/joho/godotenv/issues/30). Example `git tag -a v1.2.1`
180+
Use [annotated tags for all releases](https://github.com/mniak/godotenv/issues/30). Example `git tag -a v1.2.1`
181181

182182
## CI
183183

184-
Linux: [![Build Status](https://travis-ci.org/joho/godotenv.svg?branch=master)](https://travis-ci.org/joho/godotenv) Windows: [![Build status](https://ci.appveyor.com/api/projects/status/9v40vnfvvgde64u4)](https://ci.appveyor.com/project/joho/godotenv)
184+
Linux: [![Build Status](https://travis-ci.org/mniak/godotenv.svg?branch=master)](https://travis-ci.org/mniak/godotenv) Windows: [![Build status](https://ci.appveyor.com/api/projects/status/9v40vnfvvgde64u4)](https://ci.appveyor.com/project/mniak/godotenv)
185185

186186
## Who?
187187

autoload/autoload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ package autoload
33
/*
44
You can just read the .env file on import just by doing
55
6-
import _ "github.com/joho/godotenv/autoload"
6+
import _ "github.com/mniak/godotenv/autoload"
77
88
And bob's your mother's brother
99
*/
1010

11-
import "github.com/joho/godotenv"
11+
import "github.com/mniak/godotenv"
1212

1313
func init() {
1414
godotenv.Load()

cmd/godotenv/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"strings"
99

10-
"github.com/joho/godotenv"
10+
"github.com/mniak/godotenv"
1111
)
1212

1313
func main() {

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/mniak/godotenv
2+
3+
go 1.14

godotenv.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Package godotenv is a go port of the ruby dotenv library (https://github.com/bkeepers/dotenv)
22
//
3-
// Examples/readme can be found on the github page at https://github.com/joho/godotenv
3+
// Examples/readme can be found on the github page at https://github.com/mniak/godotenv
44
//
55
// The TL;DR is that you make a .env file that looks something like
66
//
@@ -22,6 +22,7 @@ import (
2222
"os/exec"
2323
"regexp"
2424
"sort"
25+
"strconv"
2526
"strings"
2627
)
2728

@@ -169,7 +170,11 @@ func Write(envMap map[string]string, filename string) error {
169170
func Marshal(envMap map[string]string) (string, error) {
170171
lines := make([]string, 0, len(envMap))
171172
for k, v := range envMap {
172-
lines = append(lines, fmt.Sprintf(`%s="%s"`, k, doubleQuoteEscape(v)))
173+
if d, err := strconv.Atoi(v); err == nil {
174+
lines = append(lines, fmt.Sprintf(`%s=%d`, k, d))
175+
} else {
176+
lines = append(lines, fmt.Sprintf(`%s="%s"`, k, doubleQuoteEscape(v)))
177+
}
173178
}
174179
sort.Strings(lines)
175180
return strings.Join(lines, "\n"), nil

godotenv_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,8 @@ func TestWrite(t *testing.T) {
445445
writeAndCompare(`foo="\n\r\\r!"`, `foo="\n\r\\r\!"`)
446446
// lines should be sorted
447447
writeAndCompare("foo=bar\nbaz=buzz", "baz=\"buzz\"\nfoo=\"bar\"")
448-
448+
// integers should not be quoted
449+
writeAndCompare(`key="10"`, `key=10`)
449450
}
450451

451452
func TestRoundtrip(t *testing.T) {

0 commit comments

Comments
 (0)