New Upstream Release - golang-github-makenowjust-heredoc
Ready changes
Summary
Merged new upstream version: 2.0.1 (was: 1.0.0).
Resulting package
Built on 2022-03-16T18:37 (took 1m53s)
The resulting binary packages can be installed (if you have the apt repository enabled) by running one of:
apt install -t fresh-releases golang-github-makenowjust-heredoc-dev
Lintian Result
Diff
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000..7cf33ff
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,29 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: bug
+assignees: MakeNowJust
+---
+
+## Describe the bug
+
+A clear and concise description of what the bug is.
+
+## To Reproduce
+
+**Code**:
+
+```go
+// Minimal code for reproduce the bug
+```
+
+**Expected**:
+
+**Actual**:
+
+## Environment
+
+- OS: [e.g. Windows, macOS, Linux]
+- Go: [e.g. 1.12.9]
+- Version: [e.g. 1.0.0]
diff --git a/README.md b/README.md
index e9924d2..52c8ac5 100644
--- a/README.md
+++ b/README.md
@@ -1,52 +1,48 @@
-# heredoc
-
-[![Build Status](https://circleci.com/gh/MakeNowJust/heredoc.svg?style=svg)](https://circleci.com/gh/MakeNowJust/heredoc) [![GoDoc](https://godoc.org/github.com/MakeNowJusti/heredoc?status.svg)](https://godoc.org/github.com/MakeNowJust/heredoc)
-
-## About
-
-Package heredoc provides the here-document with keeping indent.
-
-## Install
-
-```console
-$ go get github.com/MakeNowJust/heredoc
-```
-
-## Import
-
-```go
-// usual
-import "github.com/MakeNowJust/heredoc"
-```
-
-## Example
-
-```go
-package main
-
-import (
- "fmt"
- "github.com/MakeNowJust/heredoc"
-)
-
-func main() {
- fmt.Println(heredoc.Doc(`
- Lorem ipsum dolor sit amet, consectetur adipisicing elit,
- sed do eiusmod tempor incididunt ut labore et dolore magna
- aliqua. Ut enim ad minim veniam, ...
- `))
- // Output:
- // Lorem ipsum dolor sit amet, consectetur adipisicing elit,
- // sed do eiusmod tempor incididunt ut labore et dolore magna
- // aliqua. Ut enim ad minim veniam, ...
- //
-}
-```
-
-## API Document
-
- - [heredoc - GoDoc](https://godoc.org/github.com/MakeNowJust/heredoc)
-
-## License
-
-This software is released under the MIT License, see LICENSE.
+# heredoc
+
+[![Version](https://img.shields.io/github/v/release/MakeNowJust/heredoc)](https://github.com/MakeNowJust/heredoc/releases)
+[![Build Status](https://circleci.com/gh/MakeNowJust/heredoc.svg?style=svg)](https://circleci.com/gh/MakeNowJust/heredoc)
+[![GoDoc](https://godoc.org/github.com/MakeNowJusti/heredoc?status.svg)](https://godoc.org/github.com/MakeNowJust/heredoc)
+
+## About
+
+Package heredoc provides the here-document with keeping indent.
+
+## Import
+
+```go
+import "github.com/MakeNowJust/heredoc/v2"
+```
+
+## Example
+
+```go
+package main
+
+import (
+ "fmt"
+
+ "github.com/MakeNowJust/heredoc/v2"
+)
+
+func main() {
+ fmt.Println(heredoc.Doc(`
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit,
+ sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, ...
+ `))
+ // Output:
+ // Lorem ipsum dolor sit amet, consectetur adipisicing elit,
+ // sed do eiusmod tempor incididunt ut labore et dolore magna
+ // aliqua. Ut enim ad minim veniam, ...
+ //
+}
+```
+
+## API Document
+
+ - [heredoc - GoDoc](https://godoc.org/github.com/MakeNowJust/heredoc)
+
+## License
+
+This software is released under the MIT License, see LICENSE.
diff --git a/debian/changelog b/debian/changelog
index c2e9df4..62577dc 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-makenowjust-heredoc (2.0.1-1) UNRELEASED; urgency=low
+
+ * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk> Wed, 16 Mar 2022 18:35:56 -0000
+
golang-github-makenowjust-heredoc (1.0.0-1) unstable; urgency=medium
[ Alexandre Viau ]
diff --git a/dot/dot.go b/dot/dot.go
index f5cadb2..30424fa 100644
--- a/dot/dot.go
+++ b/dot/dot.go
@@ -15,7 +15,7 @@
// import (
// "fmt"
// "runtime"
-// . "github.com/MakeNowJust/heredoc/dot"
+// . "github.com/MakeNowJust/heredoc/v2/dot"
// )
//
// func main() {
@@ -27,7 +27,7 @@
// }
package heredoc_dot
-import "github.com/MakeNowJust/heredoc"
+import "github.com/MakeNowJust/heredoc/v2"
// Shortcut heredoc.Doc.
func D(raw string) string {
diff --git a/example_test.go b/example_test.go
index 0b98b89..636cd9e 100644
--- a/example_test.go
+++ b/example_test.go
@@ -6,10 +6,9 @@ package heredoc_test
import (
"fmt"
+ "github.com/MakeNowJust/heredoc/v2"
)
-import "github.com/MakeNowJust/heredoc"
-
func ExampleDoc_lipsum() {
fmt.Print(heredoc.Doc(`
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
@@ -48,7 +47,7 @@ func ExampleDoc_spec() {
func ExampleDocf() {
libName := "github.com/MakeNowJust/heredoc"
author := "TSUYUSATO Kitsune (@MakeNowJust)"
- fmt.Printf(heredoc.Docf(`
+ fmt.Print(heredoc.Docf(`
Library Name : %s
Author : %s
Repository URL: http://%s.git
diff --git a/go.mod b/go.mod
index 52b0dfd..1203ec5 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
-module github.com/MakeNowJust/heredoc
+module github.com/MakeNowJust/heredoc/v2
go 1.12
diff --git a/heredoc.go b/heredoc.go
index 1fc0469..cf54850 100644
--- a/heredoc.go
+++ b/heredoc.go
@@ -32,7 +32,6 @@ package heredoc
import (
"fmt"
"strings"
- "unicode"
)
const maxInt = int(^uint(0) >> 1)
@@ -54,6 +53,20 @@ func Doc(raw string) string {
return strings.Join(lines, "\n")
}
+// isSpace checks whether the rune represents space or not.
+// Only white spcaes (U+0020) and horizontal tabs are treated as space character.
+// It is the same as Go.
+//
+// See https://github.com/MakeNowJust/heredoc/issues/6#issuecomment-524231625.
+func isSpace(r rune) bool {
+ switch r {
+ case ' ', '\t':
+ return true
+ default:
+ return false
+ }
+}
+
// getMinIndent calculates the minimum indentation in lines, excluding empty lines.
func getMinIndent(lines []string, skipFirstLine bool) int {
minIndentSize := maxInt
@@ -64,9 +77,9 @@ func getMinIndent(lines []string, skipFirstLine bool) int {
}
indentSize := 0
- for _, r := range []rune(line) {
- if unicode.IsSpace(r) {
- indentSize += 1
+ for _, r := range line {
+ if isSpace(r) {
+ indentSize++
} else {
break
}
diff --git a/heredoc_test.go b/heredoc_test.go
index 6c53973..8eefd73 100644
--- a/heredoc_test.go
+++ b/heredoc_test.go
@@ -39,6 +39,7 @@ var tests = []testCase{
Foo
Bar
`, "Foo\nBar\n"},
+ {"\n\u3000zenkaku space", "\u3000zenkaku space"},
}
func TestDoc(t *testing.T) {
Debdiff
File lists identical (after any substitutions)
No differences were encountered in the control files