More comment tweaks to the new embed-directive

This commit is contained in:
Eli Bendersky 2022-05-24 06:28:18 -07:00
parent fc88db1814
commit 5f2ab6c8a2
3 changed files with 20 additions and 18 deletions

View File

@ -1,7 +1,8 @@
// `//go:embed` is a compiler directive that allows programs to include
// arbitrary files/folders in the binary at build time. Read more about go
// directives [here](https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives)
// and about the embed directive [here](https://pkg.go.dev/embed).
// `//go:embed` is a [compiler
// directive](https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives) that
// allows programs to include arbitrary files and folders in the Go binary at
// build time. Read more about the embed directive
// [here](https://pkg.go.dev/embed).
package main
// Import the `embed` package; if you don't use any exported
@ -10,9 +11,9 @@ import (
"embed"
)
// embed directives accept paths relative to the directory containing the
// Go source file. This directive embeds the contents of the file into a
// `string` variable.
// `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

View File

@ -1,2 +1,2 @@
82ad92029645b4fd1b5ef0cd9df3fecdf0a6764e
myu7kywm7oI
53a5e68182be7308ddb35cc209e6b905c5b9c713
p6JB_5z1IBJ

19
public/embed-directive generated
View File

@ -27,14 +27,15 @@
<tr>
<td class="docs">
<p><code>//go:embed</code> is a compiler directive that allows programs to include
arbitrary files/folders in the binary at build time. Read more about go
directives <a href="https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives">here</a>
and about the embed directive <a href="https://pkg.go.dev/embed">here</a>.</p>
<p><code>//go:embed</code> is a <a href="https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives">compiler
directive</a> that
allows programs to include arbitrary files and folders in the Go binary at
build time. Read more about the embed directive
<a href="https://pkg.go.dev/embed">here</a>.</p>
</td>
<td class="code leading">
<a href="http://play.golang.org/p/myu7kywm7oI"><img title="Run code" src="play.png" class="run" /></a><img title="Copy code" src="clipboard.png" class="copy" />
<a href="http://play.golang.org/p/p6JB_5z1IBJ"><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>
@ -59,9 +60,9 @@ identifiers from this package, you can do a blank import with <code>_ &quot;embe
<tr>
<td class="docs">
<p>embed directives accept paths relative to the directory containing the
Go source file. This directive embeds the contents of the file into a
<code>string</code> variable.</p>
<p><code>embed</code> directives accept paths relative to the directory containing the
Go source file. This directive embeds the contents of the file into the
<code>string</code> variable immediately following it.</p>
</td>
<td class="code leading">
@ -117,7 +118,7 @@ implements a simple virtual file system.</p>
<tr>
<td class="docs">
<p>Print out contents of <code>single_file.txt</code>.</p>
<p>Print out the contents of <code>single_file.txt</code>.</p>
</td>
<td class="code leading">