-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from ifooth/dev-joelei-embed
Feat: Use embed instead of packr2
- Loading branch information
Showing
14 changed files
with
933 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 0 additions & 8 deletions
8
src/backend/booster/bk_dist/controller/pkg/dashboard/dashboard-packr.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
src/backend/booster/bk_dist/controller/pkg/dashboard/packrd/packed-packr.go
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
src/backend/booster/bk_dist/dashboard/pkg/dashboard/dashboard-packr.go
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2021 THL A29 Limited, a Tencent company. All rights reserved | ||
* | ||
* This source code file is licensed under the MIT License, you may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/MIT | ||
* | ||
*/ | ||
|
||
// Package static embed static resource and index.html | ||
package static | ||
|
||
import ( | ||
"embed" | ||
"io/fs" | ||
) | ||
|
||
//go:embed controller stats | ||
var assets embed.FS | ||
|
||
// StatsFS stats 静态资源 | ||
func StatsFS() (fs.FS, error) { | ||
stats, err := fs.Sub(assets, "stats") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return stats, nil | ||
} | ||
|
||
// ControllerFS controller 静态资源 | ||
func ControllerFS() (fs.FS, error) { | ||
controller, err := fs.Sub(assets, "controller") | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return controller, nil | ||
} |
34 changes: 34 additions & 0 deletions
34
src/backend/booster/bk_dist/dashboard/static/static_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2021 THL A29 Limited, a Tencent company. All rights reserved | ||
* | ||
* This source code file is licensed under the MIT License, you may obtain a copy of the License at | ||
* | ||
* http://opensource.org/licenses/MIT | ||
* | ||
*/ | ||
|
||
package static | ||
|
||
import ( | ||
"io" | ||
"testing" | ||
) | ||
|
||
func BenchmarkStatsFS(b *testing.B) { | ||
staticFS, err := StatsFS() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for i := 0; i < b.N; i++ { | ||
f, err := staticFS.Open("index.html") | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
_, err = io.Copy(io.Discard, f) | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.