-
Notifications
You must be signed in to change notification settings - Fork 0
/
adapter.go
40 lines (33 loc) · 909 Bytes
/
adapter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package assets
import (
"fmt"
"github.com/GoFarsi/assets/entity"
"sync"
)
type logoPathPattern func(path string) string
// adaptLogoPath will format all logo paths of chains and assets by using specific pattern
func (a *AssetRepo) adaptLogoPath(patternFunc logoPathPattern) {
var wg sync.WaitGroup
adaptedChains := make(chan *entity.Chain)
for _, chain := range a.Chains {
wg.Add(1)
go func(chain *entity.Chain) {
defer wg.Done()
chain.LogoPNG = patternFunc(chain.LogoPNG)
for _, asset := range chain.Assets {
asset.LogoPNG = patternFunc(asset.LogoPNG)
}
adaptedChains <- chain
}(chain)
}
go func() {
wg.Wait()
close(adaptedChains)
}()
for range adaptedChains {
}
}
// formatPathToGithubMainRepo return a formatted path of file based on GitHub main branch
func formatFilePathByGithubRepo(path string) string {
return fmt.Sprintf("%s/%s", GithubRepoUrl, path)
}