mirror of
https://github.com/golang/go
synced 2024-11-17 18:04:48 -07:00
embed: add example
Change-Id: I4e50e469047ac7efbf4ed464e238000dbdf53d6b
GitHub-Last-Rev: 8d29b73d11
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>
This commit is contained in:
parent
e8f99da8ed
commit
0454d7346f
23
src/embed/example_test.go
Normal file
23
src/embed/example_test.go
Normal file
@ -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)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user