Skip to content

Commit

Permalink
feat: add example
Browse files Browse the repository at this point in the history
  • Loading branch information
licaonfee committed Oct 17, 2020
1 parent 32e284c commit 2ea6908
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 1 deletion.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
20 changes: 20 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
on: [ "push", "pull_request" ]
name: Run test
jobs:
checks:
name: run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: run
uses: cedrickring/[email protected]
- name: Convert coverage to lcov
uses: jandelgado/[email protected]
with:
infile: coverage.out
outfile: coverage.lcov
- name: Coveralls GitHub Action
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.lcov
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOTOOL=$(GOCMD) tool

all: deps utest cover

deps:
$(GOCMD) mod download

utest:
$(GOTEST) -race -count 1 -timeout 30s -coverprofile coverage.out ./...
cover: utest
$(GOTOOL) cover -func=coverage.out

clean:
rm -f ./coverage.out

32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,32 @@
# envy
Asbtract Environment variables

Environment variables utilities

## Usage

```go
package main

import (
"flag"
"fmt"
"github.com/licaonfee/envy"
"os"
)

func main() {
//this value should be ignored, because -my-flag is set
os.Setenv("MY_FLAG", "fooo")
//this value is passed to my-time
os.Setenv("MY_TIME", "1m")
os.Args = []string{"my-bin", "-my-flag", "bar"}
f := flag.String("my-flag", "", "my flag")
x := flag.Duration("my-time", 0, "my-time")
flag.Parse()

envy.FillFlags(flag.CommandLine)
fmt.Printf("my-flag: %s \n", *f)
fmt.Printf("my-time: %v \n", *x)
}
```

0 comments on commit 2ea6908

Please sign in to comment.