Skip to content

Commit ae6f312

Browse files
committed
reformat
1 parent 5399b7f commit ae6f312

File tree

2 files changed

+38
-38
lines changed

2 files changed

+38
-38
lines changed

cmd/cloudexec/status.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,26 @@ func PrintStatus(config config.Config, bucketName string, showAll bool) error {
2929
return time.Unix(timestamp, 0).Format("2006-01-02 15:04:05")
3030
}
3131

32-
formatElapsedTime := func(seconds int64) string {
33-
const (
34-
minute = 60
35-
hour = minute * 60
36-
day = hour * 24
37-
week = day * 7
38-
)
39-
switch {
40-
case seconds < minute * 2:
41-
return fmt.Sprintf("%d seconds", seconds)
42-
case seconds < hour * 2:
43-
return fmt.Sprintf("%d minutes", seconds/minute)
44-
case seconds < day * 2:
45-
return fmt.Sprintf("%d hours", seconds/hour)
46-
case seconds < week * 2:
47-
return fmt.Sprintf("%d days", seconds/day)
48-
default:
49-
return fmt.Sprintf("%d weeks", seconds/week)
50-
}
51-
}
32+
formatElapsedTime := func(seconds int64) string {
33+
const (
34+
minute = 60
35+
hour = minute * 60
36+
day = hour * 24
37+
week = day * 7
38+
)
39+
switch {
40+
case seconds < minute*2:
41+
return fmt.Sprintf("%d seconds", seconds)
42+
case seconds < hour*2:
43+
return fmt.Sprintf("%d minutes", seconds/minute)
44+
case seconds < day*2:
45+
return fmt.Sprintf("%d hours", seconds/hour)
46+
case seconds < week*2:
47+
return fmt.Sprintf("%d days", seconds/day)
48+
default:
49+
return fmt.Sprintf("%d weeks", seconds/week)
50+
}
51+
}
5252

5353
formatInt := func(i int64) string {
5454
return strconv.Itoa(int(i))
@@ -73,7 +73,7 @@ func PrintStatus(config config.Config, bucketName string, showAll bool) error {
7373
}
7474
return job.CompletedAt
7575
}()
76-
elapsedTime := int64(latestUpdate-job.StartedAt)
76+
elapsedTime := int64(latestUpdate - job.StartedAt)
7777
totalCost := float64(elapsedTime) / float64(3600) * job.Droplet.Size.HourlyCost
7878

7979
table.Append([]string{
@@ -85,7 +85,7 @@ func PrintStatus(config config.Config, bucketName string, showAll bool) error {
8585
formatInt(job.Droplet.Size.Disk) + " GB",
8686
formatDate(job.StartedAt),
8787
formatDate(job.UpdatedAt),
88-
formatElapsedTime(elapsedTime),
88+
formatElapsedTime(elapsedTime),
8989
"$" + formatFloat(job.Droplet.Size.HourlyCost),
9090
"$" + formatFloat(totalCost),
9191
})

pkg/digitalocean/digitalocean.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import (
1414
)
1515

1616
type Size struct {
17-
CPUs int64
18-
Disk int64
19-
Memory int64
20-
HourlyCost float64
17+
CPUs int64
18+
Disk int64
19+
Memory int64
20+
HourlyCost float64
2121
}
2222

2323
type Droplet struct {
@@ -199,10 +199,10 @@ func CreateDroplet(config config.Config, username string, region string, size st
199199
}
200200

201201
droplet.Size = Size{
202-
CPUs: int64(newDroplet.Vcpus),
203-
Disk: int64(newDroplet.Disk),
204-
Memory: int64(newDroplet.Memory),
205-
HourlyCost: float64(newDroplet.Size.PriceHourly),
202+
CPUs: int64(newDroplet.Vcpus),
203+
Disk: int64(newDroplet.Disk),
204+
Memory: int64(newDroplet.Memory),
205+
HourlyCost: float64(newDroplet.Size.PriceHourly),
206206
}
207207
droplet.Created = newDroplet.Created
208208
droplet.Name = newDroplet.Name
@@ -238,10 +238,10 @@ func GetDropletById(config config.Config, id int64) (Droplet, error) {
238238
IP: pubIp,
239239
Created: dropletInfo.Created,
240240
Size: Size{
241-
CPUs: int64(dropletInfo.Vcpus),
242-
Disk: int64(dropletInfo.Disk),
243-
Memory: int64(dropletInfo.Memory),
244-
HourlyCost: float64(dropletInfo.Size.PriceHourly),
241+
CPUs: int64(dropletInfo.Vcpus),
242+
Disk: int64(dropletInfo.Disk),
243+
Memory: int64(dropletInfo.Memory),
244+
HourlyCost: float64(dropletInfo.Size.PriceHourly),
245245
},
246246
}
247247
return droplet, nil
@@ -275,10 +275,10 @@ func GetDropletsByName(config config.Config, dropletName string) ([]Droplet, err
275275
IP: pubIp,
276276
Created: droplet.Created,
277277
Size: Size{
278-
CPUs: int64(droplet.Vcpus),
279-
Disk: int64(droplet.Disk),
280-
Memory: int64(droplet.Memory),
281-
HourlyCost: float64(droplet.Size.PriceHourly),
278+
CPUs: int64(droplet.Vcpus),
279+
Disk: int64(droplet.Disk),
280+
Memory: int64(droplet.Memory),
281+
HourlyCost: float64(droplet.Size.PriceHourly),
282282
},
283283
})
284284
}

0 commit comments

Comments
 (0)