go-ini

go-ini

A fantastic package for INI manipulations in Go

Member Since 6 years ago

Planet Earth

Experience Points
0
follower
Lessons Completed
0
follow
Best Reply Awards
3
repos
Activity
Dec
5
1 day ago
Activity icon
issue

NDagestad issue go-ini/ini

NDagestad
NDagestad

ValueWithShadows returning a non empty array when there are no values

When getting the values and shadows of a key, if there are no values at all, StringsWithShadows will return an array with an empty string. This does not seem like the right behaviour. I would expect StringsWithShadows to return an empty array if there are no values. The documentation says that ValueWithShadows returns the raw value so there is a case to be made for it to return an empty string, but I would argue it is more intuitive to return an empty array even there.

Something like this should be enough to fix it from what I can tell (it is good enough in my case at least)

diff --git a/key.go b/key.go
index 0302c29..2147974 100644
--- a/key.go
+++ b/key.go
@@ -113,6 +113,9 @@ func (k *Key) Value() string {
 // ValueWithShadows returns raw values of key and its shadows if any.
 func (k *Key) ValueWithShadows() []string {
        if len(k.shadows) == 0 {
+               if k.value == "" {
+                       return []string{}
+               }
                return []string{k.value}
        }
        vals := make([]string, len(k.shadows)+1)
started
started time in 19 hours ago
Dec
3
3 days ago
started
started time in 2 days ago
started
started time in 3 days ago
Dec
2
4 days ago
Activity icon
issue

unknwon issue comment go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

Activity icon
published release 1.66.2

unknwon in go-ini/ini create published release 1.66.2

createdAt 3 days ago
Activity icon
created tag

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

createdAt 3 days ago
push

unknwon push go-ini/ini

unknwon
unknwon

Fix nested values can span sections (#306)

commit sha: c71eccd557feacd4fcd29f322a99e98870f908b7

push time in 3 days ago
pull request

unknwon pull request go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

Activity icon
issue

codecov[bot] issue comment go-ini/ini

codecov[bot]
codecov[bot]

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

codecov[bot]
codecov[bot]

Codecov Report

Merging #306 (4abc582) into main (14e9811) will increase coverage by 0.09%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #306      +/-   ##
==========================================
+ Coverage   88.11%   88.21%   +0.09%     
==========================================
  Files           9        9              
  Lines        1355     1349       -6     
==========================================
- Hits         1194     1190       -4     
+ Misses         98       96       -2     
  Partials       63       63              
pull request

unknwon pull request go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

Activity icon
issue

unknwon issue comment go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

unknwon
unknwon

GitHub Action got stuck and does not run, I'm gonna try close and reopen the PR see if helps.

pull request

unknwon pull request go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

pull request

unknwon merge to go-ini/ini

unknwon
unknwon

Fix nested values can span sections

What problem should be fixed?

When configured with AllowNestedValues: true, the parser attempts to parse values "nested" under a key, AWS-style. To trigger this behavior, the parent key must have an empty value, and child keys must be indented. However, if the next value is in a different section, it cannot be a nested value, but the parser can treat it as such anyways. As an example:

[section]
key1 = value1
key2 =
[section2]
  key3 = value3

Before this PR, key3 is treated as a nested value under key2, and section2 has no keys.

Have you added test cases to catch the problem?

Yes, I've added tests that cover the issue and fail on the current tip of main.

started
started time in 3 days ago
Activity icon
issue

unknwon issue comment go-ini/ini

unknwon
unknwon

Fix python multiline EOF error

What problem should be fixed?

When parsing python multiline values and the key which is being parsed is the last one on the ini file and there's no new line at the end, then it throws an error. To fix that we might not consider EOF as an error when reading the last line because it's either can be a \n or EOF.

This problem was first reported here.

Have you added test cases to catch the problem?

The TestPythonMultiline_EOF was added.

Activity icon
published release 1.66.1

unknwon in go-ini/ini create published release 1.66.1

createdAt 3 days ago
Activity icon
created tag

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

createdAt 3 days ago
push

unknwon push go-ini/ini

unknwon
unknwon

Fix python multiline EOF error (#309)

commit sha: 3ca1e6ad324e3b4b4cb107e6c5117f4ec475de08

push time in 3 days ago
pull request

unknwon pull request go-ini/ini

unknwon
unknwon

Fix python multiline EOF error

What problem should be fixed?

When parsing python multiline values and the key which is being parsed is the last one on the ini file and there's no new line at the end, then it throws an error. To fix that we might not consider EOF as an error when reading the last line because it's either can be a \n or EOF.

This problem was first reported here.

Have you added test cases to catch the problem?

The TestPythonMultiline_EOF was added.

pull request

unknwon merge to go-ini/ini

unknwon
unknwon

Fix python multiline EOF error

What problem should be fixed?

When parsing python multiline values and the key which is being parsed is the last one on the ini file and there's no new line at the end, then it throws an error. To fix that we might not consider EOF as an error when reading the last line because it's either can be a \n or EOF.

This problem was first reported here.

Have you added test cases to catch the problem?

The TestPythonMultiline_EOF was added.

Dec
1
5 days ago
Activity icon
fork

Mechachleopteryx forked go-ini/ini

⚡ Package ini provides INI file read and write functionality in Go
Mechachleopteryx Apache License 2.0 Updated
fork time in 4 days ago
started
started time in 4 days ago
Activity icon
issue

codecov[bot] issue comment go-ini/ini

codecov[bot]
codecov[bot]

Fix python multiline EOF error

What problem should be fixed?

When parsing python multiline values and the key which is being parsed is the last one on the ini file and there's no new line at the end, then it throws an error. To fix that we might not consider EOF as an error when reading the last line because it's either can be a \n or EOF.

This problem was first commented here.

Have you added test cases to catch the problem?

The multiline.ini file was changed.

codecov[bot]
codecov[bot]

Codecov Report

Merging #309 (91eee1a) into main (e641746) will decrease coverage by 0.08%. The diff coverage is 0.00%.

@@            Coverage Diff             @@
##             main     #309      +/-   ##
==========================================
- Coverage   88.28%   88.20%   -0.09%     
==========================================
  Files           9        9              
  Lines        1349     1348       -1     
==========================================
- Hits         1191     1189       -2     
  Misses         96       96              
- Partials       62       63       +1     
pull request

gandarez pull request go-ini/ini

gandarez
gandarez

Fix python multiline EOF error

What problem should be fixed?

When parsing python multiline values and the key which is being parsed is the last one on the ini file and there's no new line at the end, then it throws an error. To fix that we might not consider EOF as an error when reading the last line because it's either can be a \n or EOF.

This problem was first commented here.

Have you added test cases to catch the problem?

The multiline.ini file was changed.

Nov
30
6 days ago
started
started time in 5 days ago
started
started time in 5 days ago
started
started time in 5 days ago
started
started time in 5 days ago
started
started time in 5 days ago
Previous