cloudfoundry / cloudfoundry/gosigar

GetFileSystemUsage(...) returns Kilobytes instead of Bytes

Open
#69 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Go
Stars
481
Forks
198
PR merge metrics
No merged PRs in 30d

Description

GetFileSystemUsage returns Kilobytes instead of Bytes.

Example Code which should print the used Gigabytes:

package main

import (
	"fmt"

	sigar "github.com/cloudfoundry/gosigar"
)

func main() {
	s := sigar.ConcreteSigar{}
	fsUsage, _ := s.GetFileSystemUsage("/System/Volumes/Data")

	gbUsed := float64(fsUsage.Used) / 1024 / 1024 / 1024  // converting bytes to Gigabytes
	fmt.Printf("%3.2f GB used\n", gbUsed)
}

Result on my machine:

0.34 GB used

Expected result:

> df -h
Filesystem       Size   Used  Avail Capacity iused      ifree %iused  Mounted on
...
/dev/disk3s5    460Gi  338Gi  108Gi    76% 6446774 1131120840    1%   /System/Volumes/Data
...

OS: macOS
gosigar version: 1.3.36

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the macOS-specific implementation of GetFileSystemUsage and trace how its Used value is obtained and represented. Compare the returned unit with the macOS df output shown in the issue. Done means the API reports Used in bytes, so the example's conversion produces a value consistent with df.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
operating-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.