New Upstream Snapshot - golang-github-vmihailenco-tagparser
Ready changes
Summary
Merged new upstream version: 2.0.0+ds (was: 0.1.1).
Resulting package
Built on 2022-11-23T23:56 (took 14m53s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-snapshots golang-github-vmihailenco-tagparser-dev
Lintian Result
Diff
diff --git a/.travis.yml b/.travis.yml
index ec53845..7194cd0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,10 +1,9 @@
dist: xenial
-sudo: false
language: go
go:
- - 1.11.x
- - 1.12.x
+ - 1.14.x
+ - 1.15.x
- tip
matrix:
@@ -18,7 +17,3 @@ go_import_path: github.com/vmihailenco/tagparser
before_install:
- curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.17.1
-
-script:
- - make
- - golangci-lint run
diff --git a/Makefile b/Makefile
index fe9dc5b..0b1b595 100644
--- a/Makefile
+++ b/Makefile
@@ -6,3 +6,4 @@ all:
go vet ./...
go get github.com/gordonklaus/ineffassign
ineffassign .
+ golangci-lint run
diff --git a/README.md b/README.md
index 411aa54..c0259de 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@
Install:
```shell
-go get -u github.com/vmihailenco/tagparser
+go get github.com/vmihailenco/tagparser/v2
```
## Quickstart
diff --git a/debian/changelog b/debian/changelog
index 49c3742..d744cca 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-vmihailenco-tagparser (2.0.0+ds-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk> Wed, 23 Nov 2022 23:46:47 -0000
+
golang-github-vmihailenco-tagparser (0.1.1-4) unstable; urgency=medium
[ Debian Janitor ]
diff --git a/example_test.go b/example_test.go
index c554778..9245072 100644
--- a/example_test.go
+++ b/example_test.go
@@ -3,7 +3,7 @@ package tagparser_test
import (
"fmt"
- "github.com/vmihailenco/tagparser"
+ "github.com/vmihailenco/tagparser/v2"
)
func ExampleParse() {
@@ -11,5 +11,5 @@ func ExampleParse() {
fmt.Println(tag.Name)
fmt.Println(tag.Options)
// Output: some_name
- // map[key:value key2:'complex value']
+ // map[key:value key2:complex value]
}
diff --git a/go.mod b/go.mod
index 961a46d..b3a64bf 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
-module github.com/vmihailenco/tagparser
+module github.com/vmihailenco/tagparser/v2
-go 1.13
+go 1.15
diff --git a/internal/parser/parser.go b/internal/parser/parser.go
index 2de1c6f..21a9bc7 100644
--- a/internal/parser/parser.go
+++ b/internal/parser/parser.go
@@ -3,7 +3,7 @@ package parser
import (
"bytes"
- "github.com/vmihailenco/tagparser/internal"
+ "github.com/vmihailenco/tagparser/v2/internal"
)
type Parser struct {
diff --git a/tagparser.go b/tagparser.go
index 56b9180..5002e64 100644
--- a/tagparser.go
+++ b/tagparser.go
@@ -1,7 +1,9 @@
package tagparser
import (
- "github.com/vmihailenco/tagparser/internal/parser"
+ "strings"
+
+ "github.com/vmihailenco/tagparser/v2/internal/parser"
)
type Tag struct {
@@ -31,6 +33,9 @@ type tagParser struct {
}
func (p *tagParser) setTagOption(key, value string) {
+ key = strings.TrimSpace(key)
+ value = strings.TrimSpace(value)
+
if !p.hasName {
p.hasName = true
if key == "" {
@@ -79,7 +84,6 @@ func (p *tagParser) parseKey() {
func (p *tagParser) parseValue() {
const quote = '\''
-
c := p.Peek()
if c == quote {
p.Skip(quote)
@@ -134,10 +138,7 @@ loop:
func (p *tagParser) parseQuotedValue() {
const quote = '\''
-
var b []byte
- b = append(b, quote)
-
for p.Valid() {
bb, ok := p.ReadSep(quote)
if !ok {
@@ -145,6 +146,8 @@ func (p *tagParser) parseQuotedValue() {
break
}
+ // keep the escaped single-quote, and continue until we've found the
+ // one that isn't.
if len(bb) > 0 && bb[len(bb)-1] == '\\' {
b = append(b, bb[:len(bb)-1]...)
b = append(b, quote)
@@ -152,7 +155,6 @@ func (p *tagParser) parseQuotedValue() {
}
b = append(b, bb...)
- b = append(b, quote)
break
}
@@ -162,15 +164,3 @@ func (p *tagParser) parseQuotedValue() {
}
p.parseKey()
}
-
-func Unquote(s string) (string, bool) {
- const quote = '\''
-
- if len(s) < 2 {
- return s, false
- }
- if s[0] == quote && s[len(s)-1] == quote {
- return s[1 : len(s)-1], true
- }
- return s, false
-}
diff --git a/tagparser_test.go b/tagparser_test.go
index 795dd94..7a26bab 100644
--- a/tagparser_test.go
+++ b/tagparser_test.go
@@ -3,7 +3,7 @@ package tagparser_test
import (
"testing"
- "github.com/vmihailenco/tagparser"
+ "github.com/vmihailenco/tagparser/v2"
)
var tagTests = []struct {
@@ -15,16 +15,20 @@ var tagTests = []struct {
{"hello", "hello", nil},
{"hello,world", "hello", map[string]string{"world": ""}},
- {"'hello,world'", "'hello,world'", nil},
+ {"'hello,world'", "hello,world", nil},
+ {"'hello:world'", "hello:world", nil},
{",hello", "", map[string]string{"hello": ""}},
{",hello,world", "", map[string]string{"hello": "", "world": ""}},
{"hello:", "", map[string]string{"hello": ""}},
{"hello:world", "", map[string]string{"hello": "world"}},
{"hello:world,foo", "", map[string]string{"hello": "world", "foo": ""}},
{"hello:world,foo:bar", "", map[string]string{"hello": "world", "foo": "bar"}},
- {"hello:'world1,world2'", "", map[string]string{"hello": "'world1,world2'"}},
- {`hello:'D\'Angelo', foo:bar`, "", map[string]string{"hello": "'D'Angelo'", "foo": "bar"}},
- {`hello:world('foo', 'bar')`, "", map[string]string{"hello": "world('foo', 'bar')"}},
+ {"hello:'world1,world2'", "", map[string]string{"hello": "world1,world2"}},
+ {"hello:'world1,world2',world3", "", map[string]string{"hello": "world1,world2", "world3": ""}},
+ {"hello:'world1:world2',world3", "", map[string]string{"hello": "world1:world2", "world3": ""}},
+ {`hello:'D\'Angelo, esquire', foo:bar`, "", map[string]string{"hello": "D'Angelo, esquire", "foo": "bar"}},
+ {"hello:world('foo', 'bar')", "", map[string]string{"hello": "world('foo', 'bar')"}},
+ {" hello, foo: bar ", "hello", map[string]string{"foo": "bar"}},
}
func TestTagParser(t *testing.T) {
Debdiff
File lists identical (after any substitutions)
No differences were encountered in the control files