代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/Fyne 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package fyne
import (
"io/ioutil"
"net/http"
"path/filepath"
)
// Resource represents a single binary resource, such as an image or font.
// A resource has an identifying name and byte array content.
// The serialised path of a resource can be obtained which may result in a
// blocking filesystem write operation.
type Resource interface {
Name() string
Content() []byte
}
// StaticResource is a bundled resource compiled into the application.
// These resources are normally generated by the fyne_bundle command included in
// the Fyne toolkit.
type StaticResource struct {
StaticName string
StaticContent []byte
}
// Name returns the unique name of this resource, usually matching the file it
// was generated from.
func (r *StaticResource) Name() string {
return r.StaticName
}
// Content returns the bytes of the bundled resource, no compression is applied
// but any compression on the resource is retained.
func (r *StaticResource) Content() []byte {
return r.StaticContent
}
// NewStaticResource returns a new static resource object with the specified
// name and content. Creating a new static resource in memory results in
// sharable binary data that may be serialised to the location returned by
// CachePath().
func NewStaticResource(name string, content []byte) *StaticResource {
return &StaticResource{
StaticName: name,
StaticContent: content,
}
}
// LoadResourceFromPath creates a new StaticResource in memory using the contents of the specified file.
func LoadResourceFromPath(path string) (Resource, error) {
bytes, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
name := filepath.Base(path)
return NewStaticResource(name, bytes), nil
}
// LoadResourceFromURLString creates a new StaticResource in memory using the body of the specified URL.
func LoadResourceFromURLString(urlStr string) (Resource, error) {
res, err := http.Get(urlStr)
if err != nil {
return nil, err
}
bytes, err := ioutil.ReadAll(res.Body)
if err != nil {
return nil, err
}
name := filepath.Base(urlStr)
return NewStaticResource(name, bytes), nil
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。