]> Cypherpunks.ru repositories - gostls13.git/commitdiff
embed: add example
authorhelbing <helbingxxx@gmail.com>
Tue, 12 Oct 2021 23:33:50 +0000 (23:33 +0000)
committerAlexander Rakoczy <alex@golang.org>
Wed, 13 Oct 2021 15:11:16 +0000 (15:11 +0000)
Change-Id: I4e50e469047ac7efbf4ed464e238000dbdf53d6b
GitHub-Last-Rev: 8d29b73d1160b4498a38aa3ef6530ee5c9353186
GitHub-Pull-Request: golang/go#48785
Reviewed-on: https://go-review.googlesource.com/c/go/+/353936
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>

src/embed/example_test.go [new file with mode: 0644]

diff --git a/src/embed/example_test.go b/src/embed/example_test.go
new file mode 100644 (file)
index 0000000..5498c27
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2021 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package embed_test
+
+import (
+       "embed"
+       "log"
+       "net/http"
+)
+
+//go:embed internal/embedtest/testdata/*.txt
+var content embed.FS
+
+func Example() {
+       mutex := http.NewServeMux()
+       mutex.Handle("/", http.FileServer(http.FS(content)))
+       err := http.ListenAndServe(":8080", mutex)
+       if err != nil {
+               log.Fatal(err)
+       }
+}