Skip to content

Commit 33c0f67

Browse files
committed
chore: go fmt
1 parent 44a78b2 commit 33c0f67

File tree

11 files changed

+57
-59
lines changed

11 files changed

+57
-59
lines changed

api/coingeco.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
)
1313

1414
const (
15-
marketEndpoint string = "coins/markets"
15+
marketEndpoint string = "coins/markets"
1616
marketChartEndpoint string = "coins/%s/market_chart"
1717
)
1818

@@ -89,7 +89,7 @@ func (cg *CoinGeco) Markets(ctx context.Context, currency string, perPage int) (
8989
func (cg *CoinGeco) MarketChart(ctx context.Context, id, currency string, days uint) (*common.MarketChart, error) {
9090
resp, err := cg.get(ctx, fmt.Sprintf(marketChartEndpoint, id), url.Values{
9191
"vs_currency": {currency},
92-
"days": {fmt.Sprint(days)},
92+
"days": {fmt.Sprint(days)},
9393
}, nil)
9494
if err != nil {
9595
return nil, err

api/server.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (s *Server) Markets(w http.ResponseWriter, r *http.Request) {
6060
}
6161
}
6262

63-
m, err := s.mm.Meme(strings.ToLower(market.Name), (market.PriceChange24h / market.CurrentPrice) * 100)
63+
m, err := s.mm.Meme(strings.ToLower(market.Name), (market.PriceChange24h/market.CurrentPrice)*100)
6464
if err == nil {
6565
market.Meme = m.Image
6666
c, err := meme.ParseCaption(m.Caption, market)

common/meme.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ type Range struct {
1717
type Coin struct {
1818
Name string `json:"name"`
1919
Ranges []*Range `json:"ranges"`
20-
}
20+
}

common/types.go

+37-40
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,55 @@ type ROI struct {
99
}
1010

1111
type Market struct {
12-
ID string `json:"id"`
13-
Symbol string `json:"symbol"`
14-
Name string `json:"name"`
15-
Image string `json:"image"`
16-
CurrentPrice float64 `json:"current_price"`
17-
MarketCap float64 `json:"market_cap"`
18-
MarketCapRank uint64 `json:"market_cap_rank"`
19-
FullyDilutedValuation float64 `json:"fully_diluted_valuation"`
20-
TotalVolume float64 `json:"total_volume"`
21-
High24h float64 `json:"high_24h"`
22-
Low24h float64 `json:"low_24h"`
23-
PriceChange24h float64 `json:"price_change_24h"`
24-
MarketCapChange24h float64 `json:"market_cap_change_24h"`
25-
MarketCapChangePercentage24h float64 `json:"price_change_percentage_24h"`
26-
CirculatingSupply float64 `json:"circulating_supply"`
27-
TotalSupply float64 `json:"total_supply"`
28-
MaxSupply float64 `json:"max_supply"`
29-
ATH float64 `json:"ath"`
30-
ATHChangePercentage float64 `json:"ath_change_percentage"`
31-
ATHDate time.Time `json:"ath_date"`
32-
ATL float64 `json:"atl"`
33-
ATLChangePercentage float64 `json:"atl_change_percentage"`
34-
ATLDate time.Time `json:"atl_date"`
35-
ROI *ROI `json:"roi"`
36-
LastUpdated time.Time `json:"last_updated"`
37-
38-
Meme string `json:"meme"`
39-
MemeCaption string `json:"meme_caption"`
40-
Prices7Days []*ChartPrice `json:"prices_7d"`
12+
ID string `json:"id"`
13+
Symbol string `json:"symbol"`
14+
Name string `json:"name"`
15+
Image string `json:"image"`
16+
CurrentPrice float64 `json:"current_price"`
17+
MarketCap float64 `json:"market_cap"`
18+
MarketCapRank uint64 `json:"market_cap_rank"`
19+
FullyDilutedValuation float64 `json:"fully_diluted_valuation"`
20+
TotalVolume float64 `json:"total_volume"`
21+
High24h float64 `json:"high_24h"`
22+
Low24h float64 `json:"low_24h"`
23+
PriceChange24h float64 `json:"price_change_24h"`
24+
MarketCapChange24h float64 `json:"market_cap_change_24h"`
25+
PriceChangePercentage24h float64 `json:"price_change_percentage_24h"`
26+
CirculatingSupply float64 `json:"circulating_supply"`
27+
TotalSupply float64 `json:"total_supply"`
28+
MaxSupply float64 `json:"max_supply"`
29+
ATH float64 `json:"ath"`
30+
ATHChangePercentage float64 `json:"ath_change_percentage"`
31+
ATHDate time.Time `json:"ath_date"`
32+
ATL float64 `json:"atl"`
33+
ATLChangePercentage float64 `json:"atl_change_percentage"`
34+
ATLDate time.Time `json:"atl_date"`
35+
ROI *ROI `json:"roi"`
36+
LastUpdated time.Time `json:"last_updated"`
37+
38+
Meme string `json:"meme"`
39+
MemeCaption string `json:"meme_caption"`
40+
Prices7Days []*ChartPrice `json:"prices_7d"`
4141
}
4242

4343
type ChartPrice struct {
44-
Time int64 `json:"time"`
44+
Time int64 `json:"time"`
4545
Price float64 `json:"price"`
4646
}
4747

4848
type MarketChart struct {
49-
Name string `json:"name"`
50-
Currency string `json:"currency"`
51-
RawPrices [][]float64 `json:"prices"`
52-
RawMarketCaps [][]float64 `json:"market_caps"`
49+
Name string `json:"name"`
50+
Currency string `json:"currency"`
51+
RawPrices [][]float64 `json:"prices"`
52+
RawMarketCaps [][]float64 `json:"market_caps"`
5353
RawTotalVolumes [][]float64 `json:"total_volumes"`
5454
}
5555

5656
func (m *MarketChart) Prices() []*ChartPrice {
5757
var tmp []*ChartPrice
5858
for _, p := range m.RawPrices {
5959
tmp = append(tmp, &ChartPrice{
60-
Time: int64(p[0]),
60+
Time: int64(p[0]),
6161
Price: p[1],
6262
})
6363
}
@@ -68,7 +68,7 @@ func (m *MarketChart) MarketCaps() []*ChartPrice {
6868
var tmp []*ChartPrice
6969
for _, p := range m.RawMarketCaps {
7070
tmp = append(tmp, &ChartPrice{
71-
Time: int64(p[0]),
71+
Time: int64(p[0]),
7272
Price: p[1],
7373
})
7474
}
@@ -79,12 +79,9 @@ func (m *MarketChart) TotalVolumes() []*ChartPrice {
7979
var tmp []*ChartPrice
8080
for _, p := range m.RawTotalVolumes {
8181
tmp = append(tmp, &ChartPrice{
82-
Time: int64(p[0]),
82+
Time: int64(p[0]),
8383
Price: p[1],
8484
})
8585
}
8686
return tmp
8787
}
88-
89-
90-

database/database.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ type Provider interface {
1111
Markets(ctx context.Context, t time.Time) ([]*common.Market, error)
1212
SaveMarketChart(ctx context.Context, chart *common.MarketChart) error
1313
MarketsCharts(ctx context.Context, currency string) (map[string]*common.MarketChart, error)
14-
}
14+
}

database/memory.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
)
99

1010
type MemoryCache struct {
11-
markets []*common.Market
11+
markets []*common.Market
1212
marketsCharts map[string]map[string]*common.MarketChart
13-
time time.Time
13+
time time.Time
1414
}
1515

1616
func init() {
@@ -46,4 +46,4 @@ func (m *MemoryCache) MarketsCharts(ctx context.Context, currency string) (map[s
4646
return c, nil
4747
}
4848
return nil, errors.New("currency not found")
49-
}
49+
}

internal/ent/schema/marketchart.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ func (MarketChart) Mixin() []ent.Mixin {
3939
// return []ent.Index{
4040
// index.Fields("name", "currency"),
4141
// }
42-
//}
42+
//}

main.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ func main() {
7171
defer syncr.StopAllTasks()
7272

7373
srv := service.NewService(cg, m)
74-
err = syncr.RegisterTask("markets", time.Duration(viper.GetInt("market-delay")) * time.Second, srv.SyncMarkets)
74+
err = syncr.RegisterTask("markets", time.Duration(viper.GetInt("market-delay"))*time.Second, srv.SyncMarkets)
7575
if err != nil {
7676
panic(err)
7777
}
78-
err = syncr.RegisterTask("markets-chart", time.Duration(viper.GetInt("market-chart-delay")) * time.Second, srv.SyncMarketsChart)
78+
err = syncr.RegisterTask("markets-chart", time.Duration(viper.GetInt("market-chart-delay"))*time.Second, srv.SyncMarketsChart)
7979
if err != nil {
8080
panic(err)
8181
}

meme/manager.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ func indexDataset(ds *common.MemeDataset) map[string]int {
5454
indexMap[c.Name] = i
5555
}
5656
return indexMap
57-
}
57+
}

service/service.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ type Service struct {
1717

1818
func NewService(api api.API, db database.Provider) *Service {
1919
return &Service{
20-
api: api,
21-
db: db,
20+
api: api,
21+
db: db,
2222
retryDelay: 10 * time.Second,
2323
}
2424
}
@@ -75,4 +75,4 @@ func (s *Service) SyncMarketsChart() {
7575

7676
func (s *Service) retry(f func()) {
7777
time.AfterFunc(s.retryDelay, f)
78-
}
78+
}

syncer/syncer.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ import (
99

1010
var (
1111
ErrSyncTaskAlreadyExists = errors.New("a sync task with this name already exists")
12-
ErrTaskNotFound = errors.New("task not found")
12+
ErrTaskNotFound = errors.New("task not found")
1313
)
14+
1415
type CallbackFunc func()
1516

1617
type task struct {
17-
stop chan bool
18+
stop chan bool
1819
ticker *time.Ticker
1920
}
2021

@@ -41,7 +42,7 @@ func (m *Syncer) RegisterTask(name string, delay time.Duration, callback Callbac
4142
}
4243
tsk := &task{
4344
ticker: time.NewTicker(delay),
44-
stop: make(chan bool, 1),
45+
stop: make(chan bool, 1),
4546
}
4647
m.tasks.Store(name, tsk)
4748

@@ -84,4 +85,4 @@ func (m *Syncer) StopAllTasks() {
8485
m.tasks.Delete(key)
8586
return true
8687
})
87-
}
88+
}

0 commit comments

Comments
 (0)