Documentation
¶
Overview ¶
Package fetch offers abstractions to fetch a file with the same method, regardless of a location (filesystem, HTTP...).
Example ¶
fetcher := FromHTTP("http://webserver.thethings.network/repository", true)
content, err := fetcher.File("README.md")
if err != nil {
panic(err)
}
fmt.Println("Content of http://webserver.thethings.network/repository/README.md:")
fmt.Println(string(content))
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
Interface is an abstraction for file retrieval.
func FromFilesystem ¶
FromFilesystem returns an interface that fetches files from the local filesystem
func NewMemFetcher ¶
NewMemFetcher initializes a new memory fetcher.
Example ¶
package main
import (
"fmt"
"go.thethings.network/lorawan-stack/pkg/fetch"
)
func main() {
fetcher := fetch.NewMemFetcher(map[string][]byte{
"myFile.yml": []byte("Content"),
})
content, err := fetcher.File("myFile.yml")
if err != nil {
panic(err)
}
fmt.Println("Content of myFile.yml")
fmt.Println(string(content))
}
Output:
Click to show internal directories.
Click to hide internal directories.