mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-07-15 05:01:41 +08:00
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:
@ -3,6 +3,28 @@
|
||||
|
||||
//go:build bindata
|
||||
|
||||
//go:generate go run ../../build/generate-bindata.go ../../modules/migration/schemas bindata.dat
|
||||
|
||||
package migration
|
||||
|
||||
//go:generate go run ../../build/generate-bindata.go ../../modules/migration/schemas migration bindata.go
|
||||
import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"path"
|
||||
"sync"
|
||||
|
||||
_ "embed"
|
||||
|
||||
"code.gitea.io/gitea/modules/assetfs"
|
||||
)
|
||||
|
||||
//go:embed bindata.dat
|
||||
var bindata []byte
|
||||
|
||||
var BuiltinAssets = sync.OnceValue(func() fs.FS {
|
||||
return assetfs.NewEmbeddedFS(bindata)
|
||||
})
|
||||
|
||||
func openSchema(filename string) (io.ReadCloser, error) {
|
||||
return BuiltinAssets().Open(path.Base(filename))
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
// Copyright 2022 The Gitea Authors. All rights reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
//go:build bindata
|
||||
|
||||
package migration
|
||||
|
||||
import (
|
||||
"io"
|
||||
"path"
|
||||
)
|
||||
|
||||
func openSchema(filename string) (io.ReadCloser, error) {
|
||||
return Assets.Open(path.Base(filename))
|
||||
}
|
Reference in New Issue
Block a user