Run of fresh-snapshots for golang-github-muhammadmuzzammil1998-jsonc

Merge these changes:

Summary

Merged new upstream version: 0.0~git20211231.baf1f71 (was: 0.0~git20201229.615b091).

Diff

diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml
new file mode 100644
index 0000000..7adf2f6
--- /dev/null
+++ b/.github/workflows/go.yml
@@ -0,0 +1,28 @@
+name: Go
+
+on:
+  push:
+    branches: [ master ]
+  pull_request:
+    branches: [ master ]
+
+jobs:
+
+  build:
+    runs-on: ubuntu-latest
+    steps:
+    - uses: actions/checkout@v2
+
+    - name: Set up Go
+      uses: actions/setup-go@v2
+      with:
+        go-version: 1.17
+
+    - name: Module init
+      run: go mod init github.com/muhammadmuzzammil1998/jsonc
+      
+    - name: Build
+      run: go build -v ./...
+
+    - name: Test
+      run: go test -v ./...
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index d8dcaf0..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,9 +0,0 @@
-language: go
-go:
- - 1.12.9
-notifications:
-  email:
-    recipients:
-    - muhammadmuzzammil.cs@gmail.com
-    on_success: always
-    on_failure: always
diff --git a/README.md b/README.md
index cd99332..3515bfc 100644
--- a/README.md
+++ b/README.md
@@ -4,10 +4,10 @@
 
 <p align="center">
   <i>JSON with comments for Go!</i> <br>
-  <i><a href="https://travis-ci.com/muhammadmuzzammil1998/jsonc" target="_blank"><img src="https://travis-ci.com/muhammadmuzzammil1998/jsonc.svg?branch=master" alt="travisci"></a></i>
+  <i><a href="https://github.com/muhammadmuzzammil1998/jsonc/actions/workflows/go.yml" target="_blank"><img src="https://github.com/muhammadmuzzammil1998/jsonc/actions/workflows/go.yml/badge.svg" alt="GitHub Actions"></a></i>
 </p>
 
-JSONC is a superset of JSON which supports comments. JSON formatted files are readable to humans but the lack of comments decreases readability. With JSONC, you can use block (`/* */`) and single line (`//`) comments to describe the functionality. Microsoft VS Code also uses this format in their configuration files like `settings.json`, `keybindings.json`, `launch.json`, etc.
+JSONC is a superset of JSON which supports comments. JSON formatted files are readable to humans but the lack of comments decreases readability. With JSONC, you can use block (`/* */`) and single line (`//` of `#`) comments to describe the functionality. Microsoft VS Code also uses this format in their configuration files like `settings.json`, `keybindings.json`, `launch.json`, etc.
 
 ![jsonc](carbon.png)
 
diff --git a/debian/changelog b/debian/changelog
index 5e1f99c..af8a081 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-muhammadmuzzammil1998-jsonc (0.0~git20211231.baf1f71-1) UNRELEASED; urgency=low
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Thu, 24 Mar 2022 21:04:06 -0000
+
 golang-github-muhammadmuzzammil1998-jsonc (0.0~git20201229.615b091-2) unstable; urgency=medium
 
   * Source-only upload for migration to testing
diff --git a/jsonc_test.go b/jsonc_test.go
index 9f29d6a..2a295fb 100644
--- a/jsonc_test.go
+++ b/jsonc_test.go
@@ -16,6 +16,8 @@ type testsStruct struct {
 	validSingle   []byte
 	invalidBlock  []byte
 	invalidSingle []byte
+	validHash     []byte
+	invalidHash   []byte
 }
 
 var jsonTest, jsoncTest testsStruct
@@ -30,6 +32,8 @@ func init() {
 		invalidBlock:  b(`{"foo": /* this is a block comment "bar foo", "true": false, "number": 42, "object": { "test": "done" }, "array" : [1, 2, 3], "url" : "https://github.com", "escape":"\"wo//rking }`),
 		validSingle:   b("{\"foo\": // this is a single line comm\\\"ent\n\"bar foo\", \"true\": false, \"number\": 42, \"object\": { \"test\": \"done\" }, \"array\" : [1, 2, 3], \"url\" : \"https://github.com\", \"escape\":\"\\\"wo//rking\" }"),
 		invalidSingle: b(`{"foo": // this is a single line comment "bar foo", "true": false, "number": 42, "object": { "test": "done" }, "array" : [1, 2, 3], "url" : "https://github.com", "escape":"\"wo//rking" }`),
+		validHash:     b("{\"foo\": # this is a single line comm\\\"ent\n\"bar foo\", \"true\": false, \"number\": 42, \"object\": { \"test\": \"done\" }, \"array\" : [1, 2, 3], \"url\" : \"https://github.com\", \"escape\":\"\\\"wo//rking\" }"),
+		invalidHash:   b(`{"foo": # this is a single line comment "bar foo", "true": false, "number": 42, "object": { "test": "done" }, "array" : [1, 2, 3], "url" : "https://github.com", "escape":"\"wo//rking" }`),
 	}
 }
 
@@ -58,6 +62,15 @@ func TestToJSON(t *testing.T) {
 			arg:     jsoncTest.invalidSingle,
 			want:    jsonTest.invalidBlock,
 			wantErr: true,
+		}, {
+			name: "Test for valid single line comment started with hash.",
+			arg:  jsoncTest.validHash,
+			want: jsonTest.validBlock,
+		}, {
+			name:    "Test for invalid single line comment started with hash.",
+			arg:     jsoncTest.invalidHash,
+			want:    jsonTest.invalidBlock,
+			wantErr: true,
 		},
 	}
 	for _, tt := range tests {
@@ -185,6 +198,7 @@ func BenchmarkTranslate(b *testing.B) {
 	for n := 0; n < b.N; n++ {
 		translate(jsoncTest.validSingle)
 		translate(jsoncTest.validBlock)
+		translate(jsoncTest.validHash)
 	}
 }
 
@@ -192,5 +206,6 @@ func BenchmarkValid(b *testing.B) {
 	for n := 0; n < b.N; n++ {
 		Valid(jsoncTest.validSingle)
 		Valid(jsoncTest.validBlock)
+		Valid(jsoncTest.validHash)
 	}
 }
diff --git a/translator.go b/translator.go
index ad8c63e..38320d8 100644
--- a/translator.go
+++ b/translator.go
@@ -30,6 +30,7 @@ const (
 	NEWLINE  = 10
 	ASTERISK = 42
 	SLASH    = 47
+	HASH     = 35
 )
 
 func translate(s []byte) []byte {
@@ -86,6 +87,10 @@ func translate(s []byte) []byte {
 			comment.canStart = true
 			continue
 		}
+		if ch == HASH {
+			comment.start(ch)
+			continue
+		}
 		j[i] = ch
 		i++
 	}
@@ -107,5 +112,5 @@ func (c *commentData) stop() {
 
 func (c *commentData) start(ch byte) {
 	c.startted = true
-	c.isSingleLined = ch == SLASH
+	c.isSingleLined = ch == SLASH || ch == HASH
 }

Publish Blockers

  • ☑ run was successful
  • ☑ package has not been removed from the archive
  • ☑ command has not changed
  • ☒ not yet reviewed, but review needed
  • ☑ 0 publish attempts so far.not currently attempting to back off
  • ☒ merge proposals for the package maintainer are currently being rate-limited (open: 906, max open: 300)
  • ☑ change set 73c545b0-90f2-4d36-8f91-e9cb331fa6e3 is ready

Resulting package

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-muhammadmuzzammil1998-jsonc-dev

Lintian Result

Full worker log Full build log