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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 579 additions and 368 deletions

View file

@ -118,7 +118,7 @@ func initEmbeddedExtractor(c *cli.Command) error {
func runList(_ context.Context, c *cli.Command) error {
if err := runListDo(c); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
_, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
return err
}
return nil
@ -126,7 +126,7 @@ func runList(_ context.Context, c *cli.Command) error {
func runView(_ context.Context, c *cli.Command) error {
if err := runViewDo(c); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
_, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
return err
}
return nil
@ -134,7 +134,7 @@ func runView(_ context.Context, c *cli.Command) error {
func runExtract(_ context.Context, c *cli.Command) error {
if err := runExtractDo(c); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
_, _ = fmt.Fprintf(os.Stderr, "%v\n", err)
return err
}
return nil
@ -217,7 +217,7 @@ func runExtractDo(c *cli.Command) error {
for _, a := range matchedAssetFiles {
if err := extractAsset(destdir, a, overwrite, rename); err != nil {
// Non-fatal error
fmt.Fprintf(os.Stderr, "%s: %v", a.path, err)
_, _ = fmt.Fprintf(os.Stderr, "%s: %v\n", a.path, err)
}
}