aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <m.shulhan@gmail.com>2025-02-26 23:02:29 +0700
committerShulhan <m.shulhan@gmail.com>2026-04-15 01:18:20 +0700
commitdee7a21bc9e9187a28f9001cb7367aa8ff5cfa6d (patch)
tree228e2e04153938af38e5e8435016015d84431d93
parent44f501e3482aeb8565adf23af2fc68dc080d407a (diff)
downloadgo-x-website-dee7a21bc9e9187a28f9001cb7367aa8ff5cfa6d.tar.xz
[DO-NOT-MERGE] cmd/golangorg: realign structs
This affects declaring fields in struct using field name instead of naked names.
-rw-r--r--cmd/golangorg/server.go25
1 files changed, 12 insertions, 13 deletions
diff --git a/cmd/golangorg/server.go b/cmd/golangorg/server.go
index 827dedba..7eb2b628 100644
--- a/cmd/golangorg/server.go
+++ b/cmd/golangorg/server.go
@@ -190,7 +190,7 @@ func NewHandler(contentDir, goroot string) http.Handler {
if *wikiFlag {
go watchGit(&wikiFS, "https://go.googlesource.com/wiki", "HEAD")
}
- contentFS = &mountFS{contentFS, "wiki", &wikiFS}
+ contentFS = &mountFS{old: contentFS, dir: "wiki", new: &wikiFS}
// tip.golang.org serves content from the very latest Git commit
// of the main Go repo, instead of the one the app is bundled with.
@@ -328,7 +328,7 @@ func addGopls(contentFS fs.FS, ref string) fs.FS {
if err != nil {
log.Fatalf("can't restrict to gopls/doc tree: %v", err)
}
- return &mountFS{contentFS, "gopls", goplsDocFS}
+ return &mountFS{old: contentFS, new: goplsDocFS, dir: "gopls"}
}
var gorebuild = NewCachedURL("https://gorebuild.storage.googleapis.com/gorebuild.json", 5*time.Minute)
@@ -598,9 +598,9 @@ func hostPathHandler(h http.Handler) http.Handler {
type linkRewriter struct {
http.ResponseWriter
host string
- tour bool // is this go.dev/tour/?
- buf []byte
ct string // content-type
+ buf []byte
+ tour bool // is this go.dev/tour/?
}
func (r *linkRewriter) WriteHeader(code int) {
@@ -810,7 +810,7 @@ func (fsys fixSpecsFS) Open(name string) (fs.File, error) {
case "doc/go_mem.html", "doc/go_spec.html":
data := []byte("<!--{\n\t\"Redirect\": \"/ref/" + strings.TrimPrefix(strings.TrimSuffix(name, ".html"), "doc/go_") + "\"\n}-->\n")
- return &memFile{path.Base(name), bytes.NewReader(data)}, nil
+ return &memFile{name: path.Base(name), Reader: bytes.NewReader(data)}, nil
}
return fsys.fs.Open(name)
@@ -870,8 +870,8 @@ func (s *seekableFS) Open(name string) (fs.File, error) {
// A seekableFile is a fs.File augmented by an in-memory copy of the file data to allow use of Seek.
type seekableFile struct {
- bytes.Reader
fs.File
+ bytes.Reader
}
// Read calls f.Reader.Read.
@@ -883,8 +883,8 @@ func (f *seekableFile) Read(b []byte) (int, error) {
// A memFile is an fs.File implementation backed by in-memory data.
type memFile struct {
- name string
*bytes.Reader
+ name string
}
func (f *memFile) Stat() (fs.FileInfo, error) { return f, nil }
@@ -909,8 +909,8 @@ func (a *atomicFS) Set(fsys fs.FS) {
// A mountFS is a root FS with a second FS mounted at a specific location.
type mountFS struct {
old fs.FS // root file system
- dir string // mount point
new fs.FS // fs mounted on dir
+ dir string // mount point
}
func (m *mountFS) Open(name string) (fs.File, error) {
@@ -957,14 +957,13 @@ func redirectPrefixQuery(prefix, query string) http.Handler {
}
type CachedURL struct {
+ updated time.Time
+ err error
url string
+ etag string
+ data []byte
timeout time.Duration
-
mu sync.Mutex
- data []byte
- err error
- etag string
- updated time.Time
}
func NewCachedURL(url string, timeout time.Duration) *CachedURL {