Adjust for gofmt changes in 1.19
In 1.19, gofmt slightly changes how comments are formatted; a blank `//` is inserted before `//go:embed` directives. To accommodate for that in generate.go, treat empty comment lines as part of docs segments.
This commit is contained in:
parent
742fab3f1c
commit
b4f289fe92
@ -14,16 +14,19 @@ import (
|
||||
// `embed` directives accept paths relative to the directory containing the
|
||||
// Go source file. This directive embeds the contents of the file into the
|
||||
// `string` variable immediately following it.
|
||||
//
|
||||
//go:embed folder/single_file.txt
|
||||
var fileString string
|
||||
|
||||
// Or embed the contents of the file into a `[]byte`.
|
||||
//
|
||||
//go:embed folder/single_file.txt
|
||||
var fileByte []byte
|
||||
|
||||
// We can also embed multiple files or even folders with wildcards. This uses
|
||||
// a variable of the [embed.FS type](https://pkg.go.dev/embed#FS), which
|
||||
// implements a simple virtual file system.
|
||||
//
|
||||
//go:embed folder/single_file.txt
|
||||
//go:embed folder/*.hash
|
||||
var folder embed.FS
|
||||
|
@ -1,2 +1,2 @@
|
||||
53a5e68182be7308ddb35cc209e6b905c5b9c713
|
||||
p6JB_5z1IBJ
|
||||
69526bd78ac861c85bb12b96e9f1273e8aecc5a6
|
||||
6m2ll-D52BB
|
||||
|
2
public/embed-directive
generated
2
public/embed-directive
generated
@ -35,7 +35,7 @@ build time. Read more about the embed directive
|
||||
|
||||
</td>
|
||||
<td class="code leading">
|
||||
<a href="https://go.dev/play/p/p6JB_5z1IBJ"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<a href="https://go.dev/play/p/6m2ll-D52BB"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
|
||||
<pre class="chroma">
|
||||
<span class="kn">package</span> <span class="nx">main</span>
|
||||
</pre>
|
||||
|
@ -95,8 +95,8 @@ func debug(msg string) {
|
||||
}
|
||||
}
|
||||
|
||||
var docsPat = regexp.MustCompile("^\\s*(\\/\\/|#)\\s")
|
||||
var dashPat = regexp.MustCompile("\\-+")
|
||||
var docsPat = regexp.MustCompile(`^(\s*(\/\/|#)\s|\s*\/\/$)`)
|
||||
var dashPat = regexp.MustCompile(`\-+`)
|
||||
|
||||
// Seg is a segment of an example
|
||||
type Seg struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user