Skip to content

Commit

Permalink
fix: correctly print disk sizes on 32bit systems
Browse files Browse the repository at this point in the history
The order of when the casting occurs is important.

Can be reproduced with:
```
GOARCH=386 go test  ./...
```
  • Loading branch information
jooola committed Jun 28, 2024
1 parent 12354bb commit 4992347
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/server/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ var DescribeCmd = base.DescribeCmd{
}
cmd.Printf(" - ID:\t\t%d\n", volume.ID)
cmd.Printf(" Name:\t%s\n", volume.Name)
cmd.Printf(" Size:\t%s\n", humanize.Bytes(uint64(volume.Size*humanize.GByte)))
cmd.Printf(" Size:\t%s\n", humanize.Bytes(uint64(volume.Size)*humanize.GByte))
}
} else {
cmd.Printf(" No Volumes\n")
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/volume/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var DescribeCmd = base.DescribeCmd{
cmd.Printf("ID:\t\t%d\n", volume.ID)
cmd.Printf("Name:\t\t%s\n", volume.Name)
cmd.Printf("Created:\t%s (%s)\n", util.Datetime(volume.Created), humanize.Time(volume.Created))
cmd.Printf("Size:\t\t%s\n", humanize.Bytes(uint64(volume.Size*humanize.GByte)))
cmd.Printf("Size:\t\t%s\n", humanize.Bytes(uint64(volume.Size)*humanize.GByte))
cmd.Printf("Linux Device:\t%s\n", volume.LinuxDevice)
cmd.Printf("Location:\n")
cmd.Printf(" Name:\t\t%s\n", volume.Location.Name)
Expand Down
2 changes: 1 addition & 1 deletion internal/cmd/volume/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ var ListCmd = base.ListCmd{
})).
AddFieldFn("size", output.FieldFn(func(obj interface{}) string {
volume := obj.(*hcloud.Volume)
return humanize.Bytes(uint64(volume.Size * humanize.GByte))
return humanize.Bytes(uint64(volume.Size) * humanize.GByte)
})).
AddFieldFn("location", output.FieldFn(func(obj interface{}) string {
volume := obj.(*hcloud.Volume)
Expand Down

0 comments on commit 4992347

Please sign in to comment.