More comment tweaks to the new embed-directive
This commit is contained in:
parent
fc88db1814
commit
5f2ab6c8a2
@ -1,7 +1,8 @@
|
|||||||
// `//go:embed` is a compiler directive that allows programs to include
|
// `//go:embed` is a [compiler
|
||||||
// arbitrary files/folders in the binary at build time. Read more about go
|
// directive](https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives) that
|
||||||
// directives [here](https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives)
|
// allows programs to include arbitrary files and folders in the Go binary at
|
||||||
// and about the embed directive [here](https://pkg.go.dev/embed).
|
// build time. Read more about the embed directive
|
||||||
|
// [here](https://pkg.go.dev/embed).
|
||||||
package main
|
package main
|
||||||
|
|
||||||
// Import the `embed` package; if you don't use any exported
|
// Import the `embed` package; if you don't use any exported
|
||||||
@ -10,9 +11,9 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
)
|
)
|
||||||
|
|
||||||
// embed directives accept paths relative to the directory containing the
|
// `embed` directives accept paths relative to the directory containing the
|
||||||
// Go source file. This directive embeds the contents of the file into a
|
// Go source file. This directive embeds the contents of the file into the
|
||||||
// `string` variable.
|
// `string` variable immediately following it.
|
||||||
//go:embed folder/single_file.txt
|
//go:embed folder/single_file.txt
|
||||||
var fileString string
|
var fileString string
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
82ad92029645b4fd1b5ef0cd9df3fecdf0a6764e
|
53a5e68182be7308ddb35cc209e6b905c5b9c713
|
||||||
myu7kywm7oI
|
p6JB_5z1IBJ
|
||||||
|
19
public/embed-directive
generated
19
public/embed-directive
generated
@ -27,14 +27,15 @@
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="docs">
|
<td class="docs">
|
||||||
<p><code>//go:embed</code> is a compiler directive that allows programs to include
|
<p><code>//go:embed</code> is a <a href="https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives">compiler
|
||||||
arbitrary files/folders in the binary at build time. Read more about go
|
directive</a> that
|
||||||
directives <a href="https://pkg.go.dev/cmd/compile#hdr-Compiler_Directives">here</a>
|
allows programs to include arbitrary files and folders in the Go binary at
|
||||||
and about the embed directive <a href="https://pkg.go.dev/embed">here</a>.</p>
|
build time. Read more about the embed directive
|
||||||
|
<a href="https://pkg.go.dev/embed">here</a>.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<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">
|
<pre class="chroma">
|
||||||
<span class="kn">package</span> <span class="nx">main</span>
|
<span class="kn">package</span> <span class="nx">main</span>
|
||||||
</pre>
|
</pre>
|
||||||
@ -59,9 +60,9 @@ identifiers from this package, you can do a blank import with <code>_ "embe
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="docs">
|
<td class="docs">
|
||||||
<p>embed directives accept paths relative to the directory containing the
|
<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 a
|
Go source file. This directive embeds the contents of the file into the
|
||||||
<code>string</code> variable.</p>
|
<code>string</code> variable immediately following it.</p>
|
||||||
|
|
||||||
</td>
|
</td>
|
||||||
<td class="code leading">
|
<td class="code leading">
|
||||||
@ -117,7 +118,7 @@ implements a simple virtual file system.</p>
|
|||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="docs">
|
<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>
|
||||||
<td class="code leading">
|
<td class="code leading">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user