go-ini

go-ini

A fantastic package for INI manipulations in Go

Member Since 7 years ago

Planet Earth

Experience Points
0
follower
Lessons Completed
0
follow
Best Reply Awards
3
repos
Activity
Jan
28
8 hours ago
started
started time in 8 minutes ago
started
started time in 5 hours ago
started
started time in 7 hours ago
Jan
27
1 day ago
pull request

bryanpedini pull request go-ini/docs

bryanpedini
bryanpedini

Update README.md

Corrected spelling error

Activity icon
fork

bryanpedini forked go-ini/docs

⚡ An open source project for INI documentation.
bryanpedini Updated
fork time in 9 hours ago
started
started time in 1 day ago
Jan
25
3 days ago
Activity icon
fork

yinjn1 forked go-ini/ini

⚡ Package ini provides INI file read and write functionality in Go
yinjn1 Apache License 2.0 Updated
fork time in 2 days ago
started
started time in 3 days ago
Jan
24
4 days ago
started
started time in 3 days ago
Jan
23
5 days ago
Activity icon
fork

ajunlonglive forked go-ini/ini

⚡ Package ini provides INI file read and write functionality in Go
ajunlonglive Apache License 2.0 Updated
fork time in 5 days ago
started
started time in 5 days ago
Jan
22
6 days ago
started
started time in 5 days ago
started
started time in 6 days ago
Jan
21
1 week ago
started
started time in 6 days ago
started
started time in 6 days ago
Jan
20
1 week ago
started
started time in 1 week ago
started
started time in 1 week ago
started
started time in 1 week ago
started
started time in 1 week ago
started
started time in 1 week ago
Activity icon
issue

unknwon issue go-ini/ini

unknwon
unknwon

Fail to read file: open my.ini: The system cannot find the file specified.

Version

1.16

Describe the bug

无法复现官网中开始使用的简单案例,文件夹下有main.go以及my.ini但无法读取my.ini

To reproduce


import (
	"fmt"
	"os"
	"gopkg.in/ini.v1"
)

func main() {
	cfg, err := ini.Load("my.ini")
	if err != nil {
		fmt.Printf("Fail to read file: %v", err)
		os.Exit(1)
	}

	// 典型读取操作,默认分区可以使用空字符串表示
	fmt.Println("App Mode:", cfg.Section("").Key("app_mode").String())
	fmt.Println("Data Path:", cfg.Section("paths").Key("data").String())

	// 我们可以做一些候选值限制的操作
	fmt.Println("Server Protocol:",
		cfg.Section("server").Key("protocol").In("http", []string{"http", "https"}))
	// 如果读取的值不在候选列表内,则会回退使用提供的默认值
	fmt.Println("Email Protocol:",
		cfg.Section("server").Key("protocol").In("smtp", []string{"imap", "smtp"}))

	// 试一试自动类型转换
	fmt.Printf("Port Number: (%[1]T) %[1]d\n", cfg.Section("server").Key("http_port").MustInt(9999))
	fmt.Printf("Enforce Domain: (%[1]T) %[1]v\n", cfg.Section("server").Key("enforce_domain").MustBool(false))

	// 差不多了,修改某个值然后进行保存
	cfg.Section("").Key("app_mode").SetValue("production")
	cfg.SaveTo("my.ini.local")
}

# possible values : production, development
app_mode = development

[paths]
# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
data = /home/git/grafana

[server]
# Protocol (http or https)
protocol = http

# The http port  to use
http_port = 9999

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
enforce_domain = true```

### Expected behavior

顺利学习下去QWQ

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
Activity icon
issue

unknwon issue comment go-ini/ini

unknwon
unknwon

Fail to read file: open my.ini: The system cannot find the file specified.

Version

1.16

Describe the bug

无法复现官网中开始使用的简单案例,文件夹下有main.go以及my.ini但无法读取my.ini

To reproduce


import (
	"fmt"
	"os"
	"gopkg.in/ini.v1"
)

func main() {
	cfg, err := ini.Load("my.ini")
	if err != nil {
		fmt.Printf("Fail to read file: %v", err)
		os.Exit(1)
	}

	// 典型读取操作,默认分区可以使用空字符串表示
	fmt.Println("App Mode:", cfg.Section("").Key("app_mode").String())
	fmt.Println("Data Path:", cfg.Section("paths").Key("data").String())

	// 我们可以做一些候选值限制的操作
	fmt.Println("Server Protocol:",
		cfg.Section("server").Key("protocol").In("http", []string{"http", "https"}))
	// 如果读取的值不在候选列表内,则会回退使用提供的默认值
	fmt.Println("Email Protocol:",
		cfg.Section("server").Key("protocol").In("smtp", []string{"imap", "smtp"}))

	// 试一试自动类型转换
	fmt.Printf("Port Number: (%[1]T) %[1]d\n", cfg.Section("server").Key("http_port").MustInt(9999))
	fmt.Printf("Enforce Domain: (%[1]T) %[1]v\n", cfg.Section("server").Key("enforce_domain").MustBool(false))

	// 差不多了,修改某个值然后进行保存
	cfg.Section("").Key("app_mode").SetValue("production")
	cfg.SaveTo("my.ini.local")
}

# possible values : production, development
app_mode = development

[paths]
# Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
data = /home/git/grafana

[server]
# Protocol (http or https)
protocol = http

# The http port  to use
http_port = 9999

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
enforce_domain = true```

### Expected behavior

顺利学习下去QWQ

### Additional context

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
unknwon
unknwon

Hey, please update the issue description using English so others can understand :) I'll re-open once it's been done, thank you!

started
started time in 1 week ago
started
started time in 1 week ago
Activity icon
issue

unknwon issue comment go-ini/ini

unknwon
unknwon

Return an empty array from `ValueWithShadows` if there is none

When there are no value for a given key, ValueWithShadows used to return an array containing an empty string. Instead, this PR makes it return an empty array. This change produces the same behaviour for StringsWithShadows as it uses ValueWithShadows to do it's job.

Link to the issue: https://github.com/go-ini/ini/issues/310

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code. There aren't any existing test cases for ValueWithShadows. Should I add a new one ?

PS: I tried to wait a little before doing the PR in case any newcomer wanted to use the opportunity of this simple fix for their first PR, but it's been a month now so I'll just do it myself ¯\_(ツ)_/¯

Activity icon
created tag

unknwon in go-ini/ini create tag v1.66.3

createdAt 1 week ago
Activity icon
published release 1.66.3

unknwon in go-ini/ini create published release 1.66.3

createdAt 1 week ago
push

unknwon push go-ini/ini

unknwon
unknwon

Return an empty array from ValueWithShadows if there is none (#313)

Co-authored-by: Joe Chen [email protected]

commit sha: fcd6cc399e588727c1231f4ea187d1b963536bcc

push time in 1 week ago
pull request

unknwon pull request go-ini/ini

unknwon
unknwon

Return an empty array from `ValueWithShadows` if there is none

When there are no value for a given key, ValueWithShadows used to return an array containing an empty string. Instead, this PR makes it return an empty array. This change produces the same behaviour for StringsWithShadows as it uses ValueWithShadows to do it's job.

Link to the issue: https://github.com/go-ini/ini/issues/310

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code. There aren't any existing test cases for ValueWithShadows. Should I add a new one ?

PS: I tried to wait a little before doing the PR in case any newcomer wanted to use the opportunity of this simple fix for their first PR, but it's been a month now so I'll just do it myself ¯\_(ツ)_/¯

Activity icon
issue

unknwon issue comment go-ini/ini

unknwon
unknwon

Return an empty array from `ValueWithShadows` if there is none

When there are no value for a given key, ValueWithShadows used to return an array containing an empty string. Instead, this PR makes it return an empty array. This change produces the same behaviour for StringsWithShadows as it uses ValueWithShadows to do it's job.

Link to the issue: https://github.com/go-ini/ini/issues/310

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code. There aren't any existing test cases for ValueWithShadows. Should I add a new one ?

PS: I tried to wait a little before doing the PR in case any newcomer wanted to use the opportunity of this simple fix for their first PR, but it's been a month now so I'll just do it myself ¯\_(ツ)_/¯

unknwon
unknwon
Previous