Refactor embedded assets and drop unnecessary dependencies (#34692)

Benefits:

1. smaller binary size (reduces more than 1MB)
2. better control of the assets details
3. fewer unmaintained dependencies
4. faster startup if the assets are not needed
5. won't hang up editors when open "bindata.go" by accident
This commit is contained in:
wxiaoguang
2025-06-12 11:59:33 +08:00
committed by GitHub
parent 18bafcc378
commit 65986f423f
24 changed files with 579 additions and 368 deletions

View File

@ -3,6 +3,21 @@
//go:build bindata
//go:generate go run ../../build/generate-bindata.go ../../options bindata.dat
package options
//go:generate go run ../../build/generate-bindata.go ../../options options bindata.go
import (
"sync"
_ "embed"
"code.gitea.io/gitea/modules/assetfs"
)
//go:embed bindata.dat
var bindata []byte
var BuiltinAssets = sync.OnceValue(func() *assetfs.Layer {
return assetfs.Bindata("builtin(bindata)", assetfs.NewEmbeddedFS(bindata))
})

View File

@ -1,14 +0,0 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
//go:build bindata
package options
import (
"code.gitea.io/gitea/modules/assetfs"
)
func BuiltinAssets() *assetfs.Layer {
return assetfs.Bindata("builtin(bindata)", Assets)
}