Switch to v1.0.0 of github.com/MakeNowJust/heredoc (avoid SHA)

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
Davanum Srinivas
2022-06-10 14:51:33 -04:00
parent 7e66aa3cfb
commit 3990685432
9 changed files with 28 additions and 22 deletions

View File

@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2014-2017 TSUYUSATO Kitsune
Copyright (c) 2014-2019 TSUYUSATO Kitsune
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,4 +1,6 @@
# heredoc [![CircleCI](https://circleci.com/gh/MakeNowJust/heredoc.svg?style=svg)](https://circleci.com/gh/MakeNowJust/heredoc) [![Go Walker](http://gowalker.org/api/v1/badge)](https://gowalker.org/github.com/MakeNowJust/heredoc)
# 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
@@ -15,8 +17,6 @@ $ go get github.com/MakeNowJust/heredoc
```go
// usual
import "github.com/MakeNowJust/heredoc"
// shortcuts
import . "github.com/MakeNowJust/heredoc/dot"
```
## Example
@@ -26,11 +26,11 @@ package main
import (
"fmt"
. "github.com/MakeNowJust/heredoc/dot"
"github.com/MakeNowJust/heredoc"
)
func main() {
fmt.Println(D(`
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, ...
@@ -45,8 +45,7 @@ func main() {
## API Document
- [Go Walker - github.com/MakeNowJust/heredoc](https://gowalker.org/github.com/MakeNowJust/heredoc)
- [Go Walker - github.com/MakeNowJust/heredoc/dot](https://gowalker.org/github.com/MakeNowJust/heredoc/dot)
- [heredoc - GoDoc](https://godoc.org/github.com/MakeNowJust/heredoc)
## License

View File

@@ -1,24 +1,31 @@
// Copyright (c) 2014-2017 TSUYUSATO Kitsune
// Copyright (c) 2014-2019 TSUYUSATO Kitsune
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// Package heredoc provides creation of here-documents from raw strings.
//
// Golang supports raw-string syntax.
//
// doc := `
// Foo
// Bar
// `
//
// But raw-string cannot recognize indentation. Thus such content is an indented string, equivalent to
//
// "\n\tFoo\n\tBar\n"
//
// I dont't want this!
//
// However this problem is solved by package heredoc.
//
// doc := heredoc.Doc(`
// Foo
// Bar
// `)
//
// Is equivalent to
//
// "Foo\nBar\n"
package heredoc
@@ -33,7 +40,7 @@ const maxInt = int(^uint(0) >> 1)
// Doc returns un-indented string as here-document.
func Doc(raw string) string {
skipFirstLine := false
if raw[0] == '\n' {
if len(raw) > 0 && raw[0] == '\n' {
raw = raw[1:]
} else {
skipFirstLine = true