From 0975233f47ccfcf1d0da97e672c7a29a0e7a9d64 Mon Sep 17 00:00:00 2001 From: Aofei Sheng Date: Fri, 2 Nov 2018 18:39:53 +0800 Subject: [PATCH] Add Go module --- buffer/buffer.go | 2 +- buffer/lexer.go | 2 +- buffer/lexer_test.go | 2 +- buffer/reader.go | 2 +- buffer/reader_test.go | 2 +- buffer/streamlexer.go | 2 +- buffer/streamlexer_test.go | 2 +- buffer/writer.go | 2 +- buffer/writer_test.go | 2 +- common.go | 2 +- common_test.go | 2 +- css/hash_test.go | 2 +- css/lex.go | 6 +++--- css/lex_test.go | 2 +- css/parse.go | 4 ++-- css/parse_test.go | 4 ++-- css/util.go | 4 ++-- css/util_test.go | 2 +- error.go | 2 +- go.mod | 3 +++ go.sum | 2 ++ html/hash_test.go | 2 +- html/lex.go | 6 +++--- html/lex_test.go | 4 ++-- html/util.go | 4 ++-- html/util_test.go | 2 +- js/hash_test.go | 2 +- js/lex.go | 4 ++-- js/lex_test.go | 2 +- json/parse.go | 6 +++--- json/parse_test.go | 4 ++-- position.go | 2 +- strconv/float.go | 2 +- strconv/float_test.go | 2 +- strconv/int.go | 2 +- strconv/int_test.go | 2 +- strconv/price_test.go | 2 +- svg/hash_test.go | 2 +- util.go | 2 +- util_test.go | 2 +- xml/lex.go | 6 +++--- xml/lex_test.go | 4 ++-- xml/util.go | 4 ++-- xml/util_test.go | 2 +- 44 files changed, 64 insertions(+), 59 deletions(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/buffer/buffer.go b/buffer/buffer.go index 3094aa9..9f65a56 100644 --- a/buffer/buffer.go +++ b/buffer/buffer.go @@ -5,7 +5,7 @@ The `Reader` and `Writer` types implement the `io.Reader` and `io.Writer` respec The `Lexer` type is useful for building lexers because it keeps track of the start and end position of a byte selection, and shifts the bytes whenever a valid token is found. The `StreamLexer` does the same, but keeps a buffer pool so that it reads a limited amount at a time, allowing to parse from streaming sources. */ -package buffer // import "github.com/tdewolff/parse/buffer" +package buffer // import "github.com/tdewolff/parse/v2/buffer" // defaultBufSize specifies the default initial length of internal buffers. var defaultBufSize = 4096 diff --git a/buffer/lexer.go b/buffer/lexer.go index 45c1844..e982c49 100644 --- a/buffer/lexer.go +++ b/buffer/lexer.go @@ -1,4 +1,4 @@ -package buffer // import "github.com/tdewolff/parse/buffer" +package buffer // import "github.com/tdewolff/parse/v2/buffer" import ( "io" diff --git a/buffer/lexer_test.go b/buffer/lexer_test.go index 1317dd0..92105e1 100644 --- a/buffer/lexer_test.go +++ b/buffer/lexer_test.go @@ -1,4 +1,4 @@ -package buffer // import "github.com/tdewolff/parse/buffer" +package buffer // import "github.com/tdewolff/parse/v2/buffer" import ( "bytes" diff --git a/buffer/reader.go b/buffer/reader.go index f1a0925..bb8bd4c 100644 --- a/buffer/reader.go +++ b/buffer/reader.go @@ -1,4 +1,4 @@ -package buffer // import "github.com/tdewolff/parse/buffer" +package buffer // import "github.com/tdewolff/parse/v2/buffer" import "io" diff --git a/buffer/reader_test.go b/buffer/reader_test.go index 73600ec..7d394ff 100644 --- a/buffer/reader_test.go +++ b/buffer/reader_test.go @@ -1,4 +1,4 @@ -package buffer // import "github.com/tdewolff/parse/buffer" +package buffer // import "github.com/tdewolff/parse/v2/buffer" import ( "bytes" diff --git a/buffer/streamlexer.go b/buffer/streamlexer.go index 3ed3282..56c9a4d 100644 --- a/buffer/streamlexer.go +++ b/buffer/streamlexer.go @@ -1,4 +1,4 @@ -package buffer // import "github.com/tdewolff/parse/buffer" +package buffer // import "github.com/tdewolff/parse/v2/buffer" import ( "io" diff --git a/buffer/streamlexer_test.go b/buffer/streamlexer_test.go index d37b0c1..6c066c7 100644 --- a/buffer/streamlexer_test.go +++ b/buffer/streamlexer_test.go @@ -1,4 +1,4 @@ -package buffer // import "github.com/tdewolff/parse/buffer" +package buffer // import "github.com/tdewolff/parse/v2/buffer" import ( "bytes" diff --git a/buffer/writer.go b/buffer/writer.go index ded2f36..93ad9bb 100644 --- a/buffer/writer.go +++ b/buffer/writer.go @@ -1,4 +1,4 @@ -package buffer // import "github.com/tdewolff/parse/buffer" +package buffer // import "github.com/tdewolff/parse/v2/buffer" // Writer implements an io.Writer over a byte slice. type Writer struct { diff --git a/buffer/writer_test.go b/buffer/writer_test.go index f56f5f7..fd67cb7 100644 --- a/buffer/writer_test.go +++ b/buffer/writer_test.go @@ -1,4 +1,4 @@ -package buffer // import "github.com/tdewolff/parse/buffer" +package buffer // import "github.com/tdewolff/parse/v2/buffer" import ( "fmt" diff --git a/common.go b/common.go index 3b7158e..faa053f 100644 --- a/common.go +++ b/common.go @@ -1,5 +1,5 @@ // Package parse contains a collection of parsers for various formats in its subpackages. -package parse // import "github.com/tdewolff/parse" +package parse // import "github.com/tdewolff/parse/v2" import ( "bytes" diff --git a/common_test.go b/common_test.go index a3dbcf4..19ed147 100644 --- a/common_test.go +++ b/common_test.go @@ -1,4 +1,4 @@ -package parse // import "github.com/tdewolff/parse" +package parse // import "github.com/tdewolff/parse/v2" import ( "encoding/base64" diff --git a/css/hash_test.go b/css/hash_test.go index e176cc1..0897133 100644 --- a/css/hash_test.go +++ b/css/hash_test.go @@ -1,4 +1,4 @@ -package css // import "github.com/tdewolff/parse/css" +package css // import "github.com/tdewolff/parse/v2/css" import ( "testing" diff --git a/css/lex.go b/css/lex.go index 3924bb7..71ff145 100644 --- a/css/lex.go +++ b/css/lex.go @@ -1,5 +1,5 @@ // Package css is a CSS3 lexer and parser following the specifications at http://www.w3.org/TR/css-syntax-3/. -package css // import "github.com/tdewolff/parse/css" +package css // import "github.com/tdewolff/parse/v2/css" // TODO: \uFFFD replacement character for NULL bytes in strings for example, or atleast don't end the string early @@ -8,8 +8,8 @@ import ( "io" "strconv" - "github.com/tdewolff/parse" - "github.com/tdewolff/parse/buffer" + "github.com/tdewolff/parse/v2" + "github.com/tdewolff/parse/v2/buffer" ) // TokenType determines the type of token, eg. a number or a semicolon. diff --git a/css/lex_test.go b/css/lex_test.go index 0bdc891..a2f3934 100644 --- a/css/lex_test.go +++ b/css/lex_test.go @@ -1,4 +1,4 @@ -package css // import "github.com/tdewolff/parse/css" +package css // import "github.com/tdewolff/parse/v2/css" import ( "bytes" diff --git a/css/parse.go b/css/parse.go index a1e2599..81745ae 100644 --- a/css/parse.go +++ b/css/parse.go @@ -1,11 +1,11 @@ -package css // import "github.com/tdewolff/parse/css" +package css // import "github.com/tdewolff/parse/v2/css" import ( "bytes" "io" "strconv" - "github.com/tdewolff/parse" + "github.com/tdewolff/parse/v2" ) var wsBytes = []byte(" ") diff --git a/css/parse_test.go b/css/parse_test.go index 2c1439d..7b41d10 100644 --- a/css/parse_test.go +++ b/css/parse_test.go @@ -1,4 +1,4 @@ -package css // import "github.com/tdewolff/parse/css" +package css // import "github.com/tdewolff/parse/v2/css" import ( "bytes" @@ -6,7 +6,7 @@ import ( "io" "testing" - "github.com/tdewolff/parse" + "github.com/tdewolff/parse/v2" "github.com/tdewolff/test" ) diff --git a/css/util.go b/css/util.go index 676dee8..590c83d 100644 --- a/css/util.go +++ b/css/util.go @@ -1,6 +1,6 @@ -package css // import "github.com/tdewolff/parse/css" +package css // import "github.com/tdewolff/parse/v2/css" -import "github.com/tdewolff/parse/buffer" +import "github.com/tdewolff/parse/v2/buffer" // IsIdent returns true if the bytes are a valid identifier. func IsIdent(b []byte) bool { diff --git a/css/util_test.go b/css/util_test.go index 9eb5aa9..7581559 100644 --- a/css/util_test.go +++ b/css/util_test.go @@ -1,4 +1,4 @@ -package css // import "github.com/tdewolff/parse/css" +package css // import "github.com/tdewolff/parse/v2/css" import ( "testing" diff --git a/error.go b/error.go index e790379..cd16ca0 100644 --- a/error.go +++ b/error.go @@ -4,7 +4,7 @@ import ( "fmt" "io" - "github.com/tdewolff/parse/buffer" + "github.com/tdewolff/parse/v2/buffer" ) // Error is a parsing error returned by parser. It contains a message and an offset at which the error occurred. diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d78727b --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/tdewolff/parse/v2 + +require github.com/tdewolff/test v1.0.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..6321616 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/tdewolff/test v1.0.0 h1:jOwzqCXr5ePXEPGJaq2ivoR6HOCi+D5TPfpoyg8yvmU= +github.com/tdewolff/test v1.0.0/go.mod h1:DiQUlutnqlEvdvhSn2LPGy4TFwRauAaYDsL+683RNX4= diff --git a/html/hash_test.go b/html/hash_test.go index c905ba3..fbabfff 100644 --- a/html/hash_test.go +++ b/html/hash_test.go @@ -1,4 +1,4 @@ -package html // import "github.com/tdewolff/parse/html" +package html // import "github.com/tdewolff/parse/v2/html" import ( "bytes" diff --git a/html/lex.go b/html/lex.go index b191247..f5f0ef2 100644 --- a/html/lex.go +++ b/html/lex.go @@ -1,12 +1,12 @@ // Package html is an HTML5 lexer following the specifications at http://www.w3.org/TR/html5/syntax.html. -package html // import "github.com/tdewolff/parse/html" +package html // import "github.com/tdewolff/parse/v2/html" import ( "io" "strconv" - "github.com/tdewolff/parse" - "github.com/tdewolff/parse/buffer" + "github.com/tdewolff/parse/v2" + "github.com/tdewolff/parse/v2/buffer" ) // TokenType determines the type of token, eg. a number or a semicolon. diff --git a/html/lex_test.go b/html/lex_test.go index 51d9cfa..dbccdf4 100644 --- a/html/lex_test.go +++ b/html/lex_test.go @@ -1,4 +1,4 @@ -package html // import "github.com/tdewolff/parse/html" +package html // import "github.com/tdewolff/parse/v2/html" import ( "bytes" @@ -6,7 +6,7 @@ import ( "io" "testing" - "github.com/tdewolff/parse" + "github.com/tdewolff/parse/v2" "github.com/tdewolff/test" ) diff --git a/html/util.go b/html/util.go index c8c3aab..a507e8a 100644 --- a/html/util.go +++ b/html/util.go @@ -1,6 +1,6 @@ -package html // import "github.com/tdewolff/parse/html" +package html // import "github.com/tdewolff/parse/v2/html" -import "github.com/tdewolff/parse" +import "github.com/tdewolff/parse/v2" var ( singleQuoteEntityBytes = []byte("'") diff --git a/html/util_test.go b/html/util_test.go index 3722a08..32fbefa 100644 --- a/html/util_test.go +++ b/html/util_test.go @@ -1,4 +1,4 @@ -package html // import "github.com/tdewolff/parse/html" +package html // import "github.com/tdewolff/parse/v2/html" import ( "testing" diff --git a/js/hash_test.go b/js/hash_test.go index fa6a213..05abf43 100644 --- a/js/hash_test.go +++ b/js/hash_test.go @@ -1,4 +1,4 @@ -package js // import "github.com/tdewolff/parse/js" +package js // import "github.com/tdewolff/parse/v2/js" import ( "testing" diff --git a/js/lex.go b/js/lex.go index ce4e1d5..10ff381 100644 --- a/js/lex.go +++ b/js/lex.go @@ -1,12 +1,12 @@ // Package js is an ECMAScript5.1 lexer following the specifications at http://www.ecma-international.org/ecma-262/5.1/. -package js // import "github.com/tdewolff/parse/js" +package js // import "github.com/tdewolff/parse/v2/js" import ( "io" "strconv" "unicode" - "github.com/tdewolff/parse/buffer" + "github.com/tdewolff/parse/v2/buffer" ) var identifierStart = []*unicode.RangeTable{unicode.Lu, unicode.Ll, unicode.Lt, unicode.Lm, unicode.Lo, unicode.Nl, unicode.Other_ID_Start} diff --git a/js/lex_test.go b/js/lex_test.go index 1866087..06b54ff 100644 --- a/js/lex_test.go +++ b/js/lex_test.go @@ -1,4 +1,4 @@ -package js // import "github.com/tdewolff/parse/js" +package js // import "github.com/tdewolff/parse/v2/js" import ( "bytes" diff --git a/json/parse.go b/json/parse.go index 5c78af8..dc1ed40 100644 --- a/json/parse.go +++ b/json/parse.go @@ -1,12 +1,12 @@ // Package json is a JSON parser following the specifications at http://json.org/. -package json // import "github.com/tdewolff/parse/json" +package json // import "github.com/tdewolff/parse/v2/json" import ( "io" "strconv" - "github.com/tdewolff/parse" - "github.com/tdewolff/parse/buffer" + "github.com/tdewolff/parse/v2" + "github.com/tdewolff/parse/v2/buffer" ) // GrammarType determines the type of grammar diff --git a/json/parse_test.go b/json/parse_test.go index 354a93e..4015e55 100644 --- a/json/parse_test.go +++ b/json/parse_test.go @@ -1,4 +1,4 @@ -package json // import "github.com/tdewolff/parse/json" +package json // import "github.com/tdewolff/parse/v2/json" import ( "bytes" @@ -6,7 +6,7 @@ import ( "io" "testing" - "github.com/tdewolff/parse" + "github.com/tdewolff/parse/v2" "github.com/tdewolff/test" ) diff --git a/position.go b/position.go index 690fcfa..dd4bd7e 100644 --- a/position.go +++ b/position.go @@ -5,7 +5,7 @@ import ( "io" "strings" - "github.com/tdewolff/parse/buffer" + "github.com/tdewolff/parse/v2/buffer" ) // Position returns the line and column number for a certain position in a file. It is useful for recovering the position in a file that caused an error. diff --git a/strconv/float.go b/strconv/float.go index da1a30d..df006cf 100644 --- a/strconv/float.go +++ b/strconv/float.go @@ -1,4 +1,4 @@ -package strconv // import "github.com/tdewolff/parse/strconv" +package strconv // import "github.com/tdewolff/parse/v2/strconv" import "math" diff --git a/strconv/float_test.go b/strconv/float_test.go index b1f2cfb..8158c4c 100644 --- a/strconv/float_test.go +++ b/strconv/float_test.go @@ -1,4 +1,4 @@ -package strconv // import "github.com/tdewolff/parse/strconv" +package strconv // import "github.com/tdewolff/parse/v2/strconv" import ( "fmt" diff --git a/strconv/int.go b/strconv/int.go index a84ecf3..ccaf194 100644 --- a/strconv/int.go +++ b/strconv/int.go @@ -1,4 +1,4 @@ -package strconv // import "github.com/tdewolff/parse/strconv" +package strconv // import "github.com/tdewolff/parse/v2/strconv" import ( "math" diff --git a/strconv/int_test.go b/strconv/int_test.go index 2df2cdf..b7eb20c 100644 --- a/strconv/int_test.go +++ b/strconv/int_test.go @@ -1,4 +1,4 @@ -package strconv // import "github.com/tdewolff/parse/strconv" +package strconv // import "github.com/tdewolff/parse/v2/strconv" import ( "math" diff --git a/strconv/price_test.go b/strconv/price_test.go index 3b3fccf..91ad5bb 100644 --- a/strconv/price_test.go +++ b/strconv/price_test.go @@ -1,4 +1,4 @@ -package strconv // import "github.com/tdewolff/parse/strconv" +package strconv // import "github.com/tdewolff/parse/v2/strconv" import ( "testing" diff --git a/svg/hash_test.go b/svg/hash_test.go index 7038a15..18d9c9d 100644 --- a/svg/hash_test.go +++ b/svg/hash_test.go @@ -1,4 +1,4 @@ -package svg // import "github.com/tdewolff/parse/svg" +package svg // import "github.com/tdewolff/parse/v2/svg" import ( "testing" diff --git a/util.go b/util.go index 83509a1..717a551 100644 --- a/util.go +++ b/util.go @@ -1,4 +1,4 @@ -package parse // import "github.com/tdewolff/parse" +package parse // import "github.com/tdewolff/parse/v2" // Copy returns a copy of the given byte slice. func Copy(src []byte) (dst []byte) { diff --git a/util_test.go b/util_test.go index c08c124..b4fcd24 100644 --- a/util_test.go +++ b/util_test.go @@ -1,4 +1,4 @@ -package parse // import "github.com/tdewolff/parse" +package parse // import "github.com/tdewolff/parse/v2" import ( "bytes" diff --git a/xml/lex.go b/xml/lex.go index c7ea4d1..ae8f30f 100644 --- a/xml/lex.go +++ b/xml/lex.go @@ -1,12 +1,12 @@ // Package xml is an XML1.0 lexer following the specifications at http://www.w3.org/TR/xml/. -package xml // import "github.com/tdewolff/parse/xml" +package xml // import "github.com/tdewolff/parse/v2/xml" import ( "io" "strconv" - "github.com/tdewolff/parse" - "github.com/tdewolff/parse/buffer" + "github.com/tdewolff/parse/v2" + "github.com/tdewolff/parse/v2/buffer" ) // TokenType determines the type of token, eg. a number or a semicolon. diff --git a/xml/lex_test.go b/xml/lex_test.go index d7d0e4a..ea2ca5b 100644 --- a/xml/lex_test.go +++ b/xml/lex_test.go @@ -1,4 +1,4 @@ -package xml // import "github.com/tdewolff/parse/xml" +package xml // import "github.com/tdewolff/parse/v2/xml" import ( "bytes" @@ -6,7 +6,7 @@ import ( "io" "testing" - "github.com/tdewolff/parse" + "github.com/tdewolff/parse/v2" "github.com/tdewolff/test" ) diff --git a/xml/util.go b/xml/util.go index 1501b9b..41d764b 100644 --- a/xml/util.go +++ b/xml/util.go @@ -1,6 +1,6 @@ -package xml // import "github.com/tdewolff/parse/xml" +package xml // import "github.com/tdewolff/parse/v2/xml" -import "github.com/tdewolff/parse" +import "github.com/tdewolff/parse/v2" var ( ltEntityBytes = []byte("<") diff --git a/xml/util_test.go b/xml/util_test.go index 65be6b8..502b0ed 100644 --- a/xml/util_test.go +++ b/xml/util_test.go @@ -1,4 +1,4 @@ -package xml // import "github.com/tdewolff/parse/xml" +package xml // import "github.com/tdewolff/parse/v2/xml" import ( "testing"