memory.Cached undefined
Closed this issue · 5 comments
Ran-Xing commented
./emergency-response.go:45:46: memory.Cached undefined (type *memory.Stats has no field or method Cached)
memory, err := memory.Get()
fmt.Printf("memory cached: %d GB\n", memory.Cached)
yseto commented
@Ran-Xing
On M1 Mac macOS, I seem to be able to get the value.
Please let us know what results you get if you do the following
go env
git clone https://github.com/mackerelio/go-osstat
cd go-osstat/
go run ./cmd/osstat
Ran-Xing commented
go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/xr/Library/Caches/go-build"
GOENV="/Users/xr/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/xr/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/xr/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.com.cn,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/y1/f3spxtcx0d75kn580grz4_cc0000gn/T/go-build3152992172=/tmp/go-build -gno-record-gcc-switches -fno-common"
➜ Downloads
go-osstat git:(master) go run ./cmd/osstat
loadavg.1m 2.15869140625 -
loadavg.5m 2.0712890625 -
loadavg.15m 2.1865234375 -
uptime 215162.564408 seconds
cpu.user 8565247 -
cpu.system 5371174 -
cpu.idle 96873647 -
cpu.total 110810068 -
memory.total 16401940480 bytes
memory.used 11456020480 bytes
memory.cached 4824072192 bytes
memory.free 121847808 bytes
memory.active 6091259904 bytes
memory.inactive 6061080576 bytes
memory.swap_total 2147483648 bytes
memory.swap_used 950009856 bytes
memory.swap_free 1197473792 bytes
network.gif0.rx_bytes 0 bytes
network.gif0.tx_bytes 0 bytes
network.stf0.rx_bytes 0 bytes
network.stf0.tx_bytes 0 bytes
network.anpi1.rx_bytes 0 bytes
network.anpi1.tx_bytes 0 bytes
network.anpi0.rx_bytes 0 bytes
network.anpi0.tx_bytes 0 bytes
network.ap1.rx_bytes 0 bytes
network.ap1.tx_bytes 0 bytes
network.en3.rx_bytes 0 bytes
network.en3.tx_bytes 0 bytes
network.en4.rx_bytes 0 bytes
network.en4.tx_bytes 0 bytes
network.en1.rx_bytes 0 bytes
network.en1.tx_bytes 0 bytes
network.en2.rx_bytes 0 bytes
network.en2.tx_bytes 0 bytes
network.en0.rx_bytes 41259956206 bytes
network.en0.tx_bytes 727838851 bytes
network.awdl0.rx_bytes 21218 bytes
network.awdl0.tx_bytes 169579 bytes
network.bridge0.rx_bytes 0 bytes
network.bridge0.tx_bytes 0 bytes
network.llw0.rx_bytes 0 bytes
network.llw0.tx_bytes 0 bytes
network.utun0.rx_bytes 0 bytes
network.utun0.tx_bytes 520 bytes
network.utun1.rx_bytes 0 bytes
network.utun1.tx_bytes 520 bytes
network.utun2.rx_bytes 0 bytes
network.utun2.tx_bytes 520 bytes
network.utun3.rx_bytes 496 bytes
network.utun3.tx_bytes 10936 bytes
network.utun4.rx_bytes 0 bytes
network.utun4.tx_bytes 520 bytes
➜ go-osstat git:(master)
yseto commented
go-osstat seemed to work in your environment. because this line is output.
memory.cached 4824072192 bytes
We are unable to reproduce the issue, so this issue is closed.
If you can provide details about the environment in which you can reproduce the problem, please Reopen and share the issue.