Giter VIP home page Giter VIP logo

Comments (1)

inhere avatar inhere commented on May 14, 2024

hi @Ridzhi

now, has been support : . = in default value. please see test for more detail:

config/read_test.go

Lines 366 to 405 in c56d9e3

func TestParseEnv(t *testing.T) {
ris := assert.New(t)
cfg := NewWithOptions("test", ParseEnv)
err := cfg.LoadStrings(JSON, `{
"ekey": "${EnvKey}",
"ekey0": "${ EnvKey0 }",
"ekey1": "${EnvKey1|defValue}",
"ekey2": "${ EnvKey2 | defValue1 }",
"ekey3": "${ EnvKey3 | app:run }",
"ekey4": "${FirstEnv}/${ SecondEnv }",
"ekey5": "${TEST_SHELL|/bin/bash}",
"ekey6": "${ EnvKey6 | app=run }",
"ekey7": "${ EnvKey7 | app.run }",
"ekey8": "${ EnvKey8 | app/run }"
}`)
ris.NoError(err)
tests := []struct{ EKey, EVal, CKey, CVal string }{
{"EnvKey", "EnvKey val", "ekey", "EnvKey val"},
{"EnvKey", "", "ekey", "${EnvKey}"},
{"EnvKey0", "EnvKey0 val", "ekey0", "EnvKey0 val"},
{"EnvKey3", "EnvKey3 val", "ekey3", "EnvKey3 val"},
{"EnvKey3", "", "ekey3", "app:run"},
{"EnvKey6", "", "ekey6", "app=run"},
{"EnvKey7", "", "ekey7", "app.run"},
{"EnvKey8", "", "ekey8", "app/run"},
{"TEST_SHELL", "/bin/zsh", "ekey5", "/bin/zsh"},
{"TEST_SHELL", "", "ekey5", "/bin/bash"},
}
for _, smp := range tests {
ris.Equal("", Getenv(smp.EKey))
testutil.MockEnvValue(smp.EKey, smp.EVal, func(eVal string) {
ris.Equal(smp.EVal, eVal)
ris.Equal(smp.CVal, cfg.String(smp.CKey))
})
}

from config.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.