Skip to content

Commit 846b42c

Browse files
authored
chore: repo migrate
2 parents fa7d76b + 020cdaa commit 846b42c

File tree

11 files changed

+199
-109
lines changed

11 files changed

+199
-109
lines changed

.github/workflows/coverage.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Go coverage
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.23
20+
21+
- name: Build
22+
run: go install
23+
24+
- name: Test
25+
run: |
26+
go test -v -cover ./... -coverprofile coverage.out -coverpkg ./...
27+
28+
- name: Report Coveralls
29+
uses: coverallsapp/github-action@v2
30+
with:
31+
file: "*.out"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.vscode
2+
*.out

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# 🛠️ go-config: Universal Configuration Library for Go
22

3-
[![Go Reference](https://pkg.go.dev/badge/github.com/hikitani/go-config.svg)](https://pkg.go.dev/github.com/hikitani/go-config)
4-
[![Go Report Card](https://goreportcard.com/badge/github.com/hikitani/go-config)](https://goreportcard.com/report/github.com/hikitani/go-config)
5-
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
3+
<p align="center">
4+
<img src="https://img.shields.io/github/license/MordaTeam/go-config" alt="License">
5+
<img alt="Static Badge" src="https://img.shields.io/badge/lang-golang-blue">
6+
<a href='https://coveralls.io/github/MordaTeam/go-config?branch=main'><img src='https://coveralls.io/repos/github/MordaTeam/go-config/badge.svg?branch=main' alt='Coverage Status' /></a>
7+
<a href="https://goreportcard.com/report/github.com/MordaTeam/go-config"><img src="https://goreportcard.com/badge/github.com/MordaTeam/go-config" alt="Go Reference"></a>
8+
<a href="https://pkg.go.dev/github.com/MordaTeam/go-config"><img src="https://pkg.go.dev/badge/github.com/MordaTeam/go-config.svg" alt="Go Reference"></a>
9+
</p>
610

711
`go-config` is a universal library for Go that simplifies working with configuration files and data from various sources. The library provides a flexible interface for loading, decoding, and merging configurations.
812

@@ -35,7 +39,7 @@
3539
## 📦 Installation
3640

3741
```bash
38-
go get github.com/hikitani/go-config
42+
go get github.com/MordaTeam/go-config
3943
```
4044

4145
---

cmdline_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ package config_test
22

33
import (
44
"os"
5+
"path"
56
"strings"
67
"testing"
78

8-
"github.com/hikitani/go-config"
9+
"github.com/MordaTeam/go-config"
910
"github.com/stretchr/testify/assert"
1011
"github.com/stretchr/testify/require"
1112
)
@@ -41,10 +42,14 @@ Help Options:
4142
4243
`
4344

44-
tmpfile, err := os.CreateTemp("", "test-stdout-*")
45+
tmpfile, err := os.Create(path.Join(t.TempDir(), "test-stdout"))
4546
require.NoError(t, err)
46-
t.Cleanup(func() { _ = tmpfile.Close() })
47+
stdout := os.Stdout
4748
os.Stdout = tmpfile
49+
t.Cleanup(func() {
50+
_ = tmpfile.Close()
51+
os.Stdout = stdout
52+
})
4853

4954
defer func() {
5055
// os.Exit catching

consul_test.go

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import (
55
"io"
66
"testing"
77

8+
"github.com/MordaTeam/go-config"
89
"github.com/docker/go-connections/nat"
910
"github.com/hashicorp/consul/api"
10-
"github.com/hikitani/go-config"
1111
"github.com/stretchr/testify/require"
1212
"github.com/testcontainers/testcontainers-go/modules/consul"
1313
"github.com/testcontainers/testcontainers-go/network"
@@ -32,9 +32,10 @@ func TestConsulProvider(t *testing.T) {
3232
port, err := consulContainer.MappedPort(ctx, nat.Port("8500"))
3333
r.NoError(err)
3434

35-
client, err := api.NewClient(&api.Config{
35+
clientCfg := &api.Config{
3636
Address: ip + ":" + port.Port(),
37-
})
37+
}
38+
client, err := api.NewClient(clientCfg)
3839
r.NoError(err)
3940

4041
_, err = client.KV().Put(&api.KVPair{
@@ -43,13 +44,29 @@ func TestConsulProvider(t *testing.T) {
4344
}, &api.WriteOptions{})
4445
r.NoError(err)
4546

46-
dataReader, err := config.
47-
FromConsul("/foo/bar", config.ConsulWithClient(client)).
48-
ProvideConfig()
49-
r.NoError(err)
47+
t.Run("DefaultClient", func(t *testing.T) {
48+
t.Setenv("CONSUL_HTTP_ADDR", clientCfg.Address)
5049

51-
data, err := io.ReadAll(dataReader)
52-
r.NoError(err)
50+
dataReader, err := config.
51+
FromConsul("/foo/bar").
52+
ProvideConfig()
53+
r.NoError(err)
5354

54-
r.Equal([]byte(`{"foo": "bar"}`), data)
55+
data, err := io.ReadAll(dataReader)
56+
r.NoError(err)
57+
58+
r.Equal([]byte(`{"foo": "bar"}`), data)
59+
})
60+
61+
t.Run("CustomClient", func(t *testing.T) {
62+
dataReader, err := config.
63+
FromConsul("/foo/bar", config.ConsulWithClient(client)).
64+
ProvideConfig()
65+
r.NoError(err)
66+
67+
data, err := io.ReadAll(dataReader)
68+
r.NoError(err)
69+
70+
r.Equal([]byte(`{"foo": "bar"}`), data)
71+
})
5572
}

env_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"strings"
66
"testing"
77

8-
"github.com/hikitani/go-config"
8+
"github.com/MordaTeam/go-config"
99
"github.com/stretchr/testify/assert"
1010
"github.com/stretchr/testify/require"
1111
)

file_test.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package config_test
2+
3+
import (
4+
"os"
5+
"path"
6+
"testing"
7+
8+
"github.com/MordaTeam/go-config"
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
type testConfig struct {
13+
Foo string `json:"foo"`
14+
}
15+
16+
func TestFile(t *testing.T) {
17+
filePath := path.Join(t.TempDir(), "config.json")
18+
file, err := os.Create(filePath)
19+
require.NoError(t, err)
20+
21+
_, err = file.WriteString(`{"foo": "bar"}`)
22+
require.NoError(t, err)
23+
require.NoError(t, file.Close())
24+
25+
cfg, err := config.New[testConfig](config.FromFile(filePath))
26+
require.NoError(t, err)
27+
require.Equal(t, "bar", cfg.Foo)
28+
}

go.mod

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
module github.com/hikitani/go-config
1+
module github.com/MordaTeam/go-config
22

3-
go 1.23.4
3+
go 1.22.12
44

55
require (
66
github.com/docker/go-connections v0.5.0
77
github.com/stretchr/testify v1.10.0
8-
github.com/testcontainers/testcontainers-go/modules/consul v0.36.0
8+
github.com/testcontainers/testcontainers-go/modules/consul v0.35.0
99
)
1010

1111
require (
12-
dario.cat/mergo v1.0.1 // indirect
12+
dario.cat/mergo v1.0.0 // indirect
1313
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
1414
github.com/Microsoft/go-winio v0.6.2 // indirect
1515
github.com/armon/go-metrics v0.4.1 // indirect
1616
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
17+
github.com/containerd/containerd v1.7.18 // indirect
1718
github.com/containerd/log v0.1.0 // indirect
1819
github.com/containerd/platforms v0.2.1 // indirect
1920
github.com/cpuguy83/dockercfg v0.3.2 // indirect
21+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2022
github.com/distribution/reference v0.6.0 // indirect
21-
github.com/docker/docker v28.0.1+incompatible // indirect
23+
github.com/docker/docker v27.1.1+incompatible // indirect
2224
github.com/docker/go-units v0.5.0 // indirect
23-
github.com/ebitengine/purego v0.8.2 // indirect
2425
github.com/fatih/color v1.16.0 // indirect
2526
github.com/felixge/httpsnoop v1.0.4 // indirect
26-
github.com/go-logr/logr v1.4.2 // indirect
27+
github.com/go-logr/logr v1.4.1 // indirect
2728
github.com/go-logr/stdr v1.2.2 // indirect
2829
github.com/go-ole/go-ole v1.2.6 // indirect
2930
github.com/gogo/protobuf v1.3.2 // indirect
@@ -38,7 +39,7 @@ require (
3839
github.com/hashicorp/serf v0.10.1 // indirect
3940
github.com/klauspost/compress v1.17.4 // indirect
4041
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
41-
github.com/magiconair/properties v1.8.9 // indirect
42+
github.com/magiconair/properties v1.8.7 // indirect
4243
github.com/mattn/go-colorable v0.1.13 // indirect
4344
github.com/mattn/go-isatty v0.0.20 // indirect
4445
github.com/mitchellh/go-homedir v1.1.0 // indirect
@@ -47,39 +48,32 @@ require (
4748
github.com/moby/patternmatcher v0.6.0 // indirect
4849
github.com/moby/sys/sequential v0.5.0 // indirect
4950
github.com/moby/sys/user v0.1.0 // indirect
50-
github.com/moby/sys/userns v0.1.0 // indirect
5151
github.com/moby/term v0.5.0 // indirect
5252
github.com/morikuni/aec v1.0.0 // indirect
5353
github.com/opencontainers/go-digest v1.0.0 // indirect
54-
github.com/opencontainers/image-spec v1.1.1 // indirect
54+
github.com/opencontainers/image-spec v1.1.0 // indirect
5555
github.com/pkg/errors v0.9.1 // indirect
56+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
5657
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
57-
github.com/shirou/gopsutil/v4 v4.25.1 // indirect
58+
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
59+
github.com/shoenig/go-m1cpu v0.1.6 // indirect
5860
github.com/sirupsen/logrus v1.9.3 // indirect
5961
github.com/tklauser/go-sysconf v0.3.12 // indirect
6062
github.com/tklauser/numcpus v0.6.1 // indirect
61-
github.com/yusufpapurcu/wmi v1.2.4 // indirect
62-
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
63+
github.com/yusufpapurcu/wmi v1.2.3 // indirect
6364
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
64-
go.opentelemetry.io/otel v1.35.0 // indirect
65-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.35.0 // indirect
66-
go.opentelemetry.io/otel/metric v1.35.0 // indirect
67-
go.opentelemetry.io/otel/sdk v1.35.0 // indirect
68-
go.opentelemetry.io/otel/trace v1.35.0 // indirect
69-
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
70-
golang.org/x/crypto v0.35.0 // indirect
65+
go.opentelemetry.io/otel v1.24.0 // indirect
66+
go.opentelemetry.io/otel/metric v1.24.0 // indirect
67+
go.opentelemetry.io/otel/trace v1.24.0 // indirect
68+
golang.org/x/crypto v0.31.0 // indirect
7169
golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect
72-
golang.org/x/sys v0.31.0 // indirect
73-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250414145226-207652e42e2e // indirect
74-
google.golang.org/protobuf v1.36.6 // indirect
70+
golang.org/x/sys v0.29.0 // indirect
7571
)
7672

7773
require (
7874
github.com/caarlos0/env/v9 v9.0.0
79-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
8075
github.com/hashicorp/consul/api v1.32.0
8176
github.com/jessevdk/go-flags v1.6.1
82-
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
83-
github.com/testcontainers/testcontainers-go v0.36.0
77+
github.com/testcontainers/testcontainers-go v0.35.0
8478
gopkg.in/yaml.v3 v3.0.1 // indirect
8579
)

0 commit comments

Comments
 (0)