psutil for golang

gopsutil: psutil for golang

https://coveralls.io/repos/shirou/gopsutil/badge.svg?branch=master

This is a port of psutil (https://github.com/giampaolo/psutil). The challenge is porting all psutil functions on some architectures.

v3 migration

from v3.20.10, gopsutil becomes v3 which breaks backawards compatiblity. See v3Changes.md more detail changes.

Tag semantics

gopsutil tag policy is almost same as Semantic Versioning, but automatically increase like Ubuntu versioning.

for example, v2.17.04 means

  • v2: major version
  • 17: release year, 2017
  • 04: release month

gopsutil aims to keep backwards-compatiblity until major version change.

Taged at every end of month, but there are only a few commits, it can be skipped.

Available Architectures

  • FreeBSD i386/amd64/arm
  • Linux i386/amd64/arm(raspberry pi)
  • Windows/amd64
  • Darwin i386/amd64
  • OpenBSD amd64 (Thank you @mpfz0r!)
  • Solaris amd64 (developed and tested on SmartOS/Illumos, Thank you @jen20!)

These are partial support:

  • CPU on DragonFly BSD (#893, Thank you @gballet!)
  • host on Linux RISC-V (#896, Thank you @tklauser!)

All works are implemented without cgo by porting c struct to golang struct.

Usage

package main

import (
    "fmt"

    "github.com/shirou/gopsutil/v3/mem"
    // "github.com/shirou/gopsutil/mem"  // to use v2
)

func main() {
    v, _ := mem.VirtualMemory()

    // almost every return value is a struct
    fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", v.Total, v.Free, v.UsedPercent)

    // convert to JSON. String() is also implemented
    fmt.Println(v)
}

The output is below.

Total: 3179569152, Free:284233728, UsedPercent:84.508194%
{"total":3179569152,"available":492572672,"used":2895335424,"usedPercent":84.50819439828305, (snip...)}

You can set an alternative location to /proc by setting the HOST_PROC environment variable.

You can set an alternative location to /sys by setting the HOST_SYS environment variable.

You can set an alternative location to /etc by setting the HOST_ETC environment variable.

You can set an alternative location to /var by setting the HOST_VAR environment variable.

You can set an alternative location to /run by setting the HOST_RUN environment variable.

You can set an alternative location to /dev by setting the HOST_DEV environment variable.

Documentation

see http://godoc.org/github.com/shirou/gopsutil

Requirements

  • go1.11 or above is required.

More Info

Several methods have been added which are not present in psutil, but will provide useful information.

  • host/HostInfo() (linux)
    • Hostname
    • Uptime
    • Procs
    • OS (ex: "linux")
    • Platform (ex: "ubuntu", "arch")
    • PlatformFamily (ex: "debian")
    • PlatformVersion (ex: "Ubuntu 13.10")
    • VirtualizationSystem (ex: "LXC")
    • VirtualizationRole (ex: "guest"/"host")
  • IOCounters
  • cpu/CPUInfo() (linux, freebsd)
    • CPU (ex: 0, 1, ...)
    • VendorID (ex: "GenuineIntel")
    • Family
    • Model
    • Stepping
    • PhysicalID
    • CoreID
    • Cores (ex: 2)
    • ModelName (ex: "Intel(R) Core(TM) i7-2640M CPU @ 2.80GHz")
    • Mhz
    • CacheSize
    • Flags (ex: "fpu vme de pse tsc msr pae mce cx8 ...")
    • Microcode
  • load/LoadAvg() (linux, freebsd)
    • Load1
    • Load5
    • Load15
  • docker/GetDockerIDList() (linux only)
    • container id list ([]string)
  • docker/CgroupCPU() (linux only)
    • user
    • system
  • docker/CgroupMem() (linux only)
    • various status
  • net_protocols (linux only)
    • system wide stats on network protocols (i.e IP, TCP, UDP, etc.)
    • sourced from /proc/net/snmp
  • iptables nf_conntrack (linux only)
    • system wide stats on netfilter conntrack module
    • sourced from /proc/sys/net/netfilter/nf_conntrack_count

Some codes are ported from Ohai. many thanks.

Current Status

  • x: work
  • b: almost works, but something is broken

Process class

name Linux FreeBSD OpenBSD MacOSX Windows
pid x x x x x
ppid x x x x x
name x x x x x
cmdline x x   x x
create_time x     x x
status x x x x  
cwd x        
exe x x x   x
uids x x x x  
gids x x x x  
terminal x x x x  
io_counters x x x   x
nice x x x x x
num_fds x        
num_ctx_switches x        
num_threads x x x x x
cpu_times x       x
memory_info x x x x x
memory_info_ex x        
memory_maps x        
open_files x        
send_signal x x x x  
suspend x x x x  
resume x x x x  
terminate x x x x x
kill x x x x  
username x x x x x
ionice          
rlimit x        
num_handlers          
threads x        
cpu_percent x   x x  
cpu_affinity          
memory_percent          
parent x   x x x
children x x x x x
connections x   x x  
is_running          
page_faults x        

Original Metrics

item Linux FreeBSD OpenBSD MacOSX Windows Solaris
HostInfo            
hostname x x x x x x
uptime x x x x   x
proces x x x     x
os x x x x x x
platform x x x x   x
platformfamily x x x x   x
virtualization x          
CPU            
VendorID x x x x x x
Family x x x x x x
Model x x x x x x
Stepping x x x x x x
PhysicalID x         x
CoreID x         x
Cores x       x x
ModelName x x x x x x
Microcode x         x
LoadAvg            
Load1 x x x x    
Load5 x x x x    
Load15 x x x x    
GetDockerID            
container id x no no no no  
CgroupsCPU            
user x no no no no  
system x no no no no  
CgroupsMem            
various x no no no no  
  • future work
    • process_iter
    • wait_procs
    • Process class
      • as_dict
      • wait

License

New BSD License (same as psutil)

Related Works

I have been influenced by the following great works:

How to Contribute

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

My English is terrible, so documentation or correcting comments are also welcome.

Comments
  • Make types for OpenBSD/arm64

    Make types for OpenBSD/arm64

    As requested here.

    These were generated on OpenBSD-current on a Raspberry Pi 4.

    Can you tell me how to test the build and run the test suite? I don't know anything about golang!

    Fixes #992

  • proc.Percent()

    proc.Percent()

    I am trying to get cpu usage for a process. However, I am getting 0 as the value always. Below is my sample code. I am using telegraf procstat plugin. Even there it's returning 0 value

    ` func main() {

    var pid int32
    pid = 10172
    proc, _ := process.NewProcess(pid)
    p, err := proc.Percent(time.Duration(0))
    if err != nil {
       fmt.Println(err)
    }
    

    }`

    Thanks

  • Mhz copied to CPU on FreeBSD

    Mhz copied to CPU on FreeBSD

    I noticed CPU outputs value of MHz instead of number on CPUs. I thought CPU is used to output number of physical CPUs.

    I think dmesg might help here to get the right number. Here are a few examples from our servers

    • (2phys CPUs no HT) FreeBSD/SMP: 2 package(s) x 4 core(s) hw.ncpu=8
    • (1 phys CPUs) FreeBSD/SMP: 1 package(s) x 2 core(s) x 2 hardware threads hw.ncpu=4
    • (1 phys CPUs) FreeBSD/SMP: 1 package(s) x 4 core(s) x 2 SMT threads hw.ncpu=8
    • (1 phys CPUs) FreeBSD/SMP: 1 package(s) x 6 core(s) x 2 SMT threads hw.ncpu=12
  • disk: device mapper name in linux

    disk: device mapper name in linux

    I would like to support device mapper naming in linux for the disk module.

    It's not as exotic as it sounds, eg LVM devices get a mapper name; but my main interest is is multipath devices.

    to get the name, there's following https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-block-dm

    so given device name abc it is as easy as trying to get the content of /sys/block/abc/dm/name. it will be empty for non-dm devices and for older kernels or system without /sys mounted

    my main question is: would such feature get merged? and if so, what attributename can i use for that?

    i would implement it similar to getSerialNumber and maybe add it in IOCounter as d.DMName = getDeviceMapperName(), similar to the way the serial number is added.

  • Fix broken retrieval of OpenBSD CPU metrics

    Fix broken retrieval of OpenBSD CPU metrics

    CPU metrics are broken on OpenBSD 7.0-CURRENT as described in #1239. I believe that the problem is the multiplication of the CPU incrementer by 2 when the code walks through the available CPUs to gather CPU time metrics. The code makes uses of the KERN_CPTIME2 sysctl to fetch per-CPU time metrics.

    Looking at the kernel code behind this particular sysctl, we have this.. As you can see, it's calling a CPU_INFO_FOREACH macro and iterating through the results until it has the info for the requested CPU. This macro is defined per-architecture and in every one that I found, it's just iterating through cpu_info structs defined here.

    I can't find anything that leads me to believe that this Go code should be incrementing by anything other than 1.

    In the entire OpenBSD codebase, there's only one use of the KERN_CPTIME2 sysctl and that's in snmpd's source code, which iterates through the CPUs and it does this by incrementing the counter by 1.

    This particular code ^ hasn't changed since 2016 and I'll bet it still works. :-)

    Here's another clue. As I mentioned, the guts of this syscall is just iterating through cpu_info struct. I looked around for other uses of this struct and found code for the new OpenBSD debugger. There are different implementations for different architectures, but for amd64, it also increments through CPUs by 1.

    Here is a PR to fix this. I only have one OpenBSD machine to test on, a simple Dell Optiplex workstation.

  • Cache common/common_linux.Virtualization()

    Cache common/common_linux.Virtualization()

    By assuming virtualization environment won't change during a the program's runtime, we can cache common/common_linux.Virtualization() with a simple map to reduce amount of system calls. I first mentioned this issue at 890

  • go.mod does not specify v2 version

    go.mod does not specify v2 version

    The go.mod file in this repo does not specify the /v2 tag so if this module is imported in any project, it will be imported with +incompatible From the official documentation (https://github.com/golang/go/wiki/Modules)

    The module path (such as module foo/v2) declared at the start of a module's go.mod file is both: the definitive declaration of that module's identity the definitive declaration of how that module must be imported by consuming code

    A module can import a v2+ package that has not opted in to modules itself. A non-module v2+ package that has a valid v2+ semver tag will be recorded with an +incompatible suffix in the importing module's go.mod file. The +incompatible suffix indicates that even though the v2+ package has a valid v2+ semver tag such as v2.0.0, the v2+ package has not actively opted in to modules and hence that v2+ package is assumed to have not been created with an understanding of the implications of Semantic Import Versioning and how to use major versions in import paths. Therefore, when operating in module mode, the go tool will treat a non-module v2+ package as an (incompatible) extension of the v1 version series of the package and assume the package has no awareness of Semantic Import Versioning, and the +incompatible suffix is an indication that the go tool is doing so.

    Tested this on centos linux and saw this in my go.mod file github.com/shirou/gopsutil v2.18.12+incompatible When I tested this, the current tag was 2.19.03 My go version go version go1.11 linux/amd64

  • add bedrock linux support

    add bedrock linux support

    on bedrock linux installs, gopsutil improperly detects the operating system as the operating system of the strata the program is being run from. this pull request adds in another utility function that detects the /bedrock folder at the root of the system and if it finds it, it changes the files being read from and properly detects the operating system as being bedrock linux

  • Deprecated code in macOS Monterey

    Deprecated code in macOS Monterey

    Describe the bug There is a deprecation messages while building code with gopsutil v3.

    # github.com/shirou/gopsutil/disk
    iostat_darwin.c:28:2: warning: 'IOMasterPort' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:132:1: note: 'IOMasterPort' has been explicitly marked deprecated here
    # github.com/shirou/gopsutil/host
    smc_darwin.c:75:41: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
    /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:123:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here
    

    To Reproduce

    package main
    
    import (
    	_ "github.com/shirou/gopsutil/cpu"
    	_ "github.com/shirou/gopsutil/disk"
    	_ "github.com/shirou/gopsutil/host"
    	_ "github.com/shirou/gopsutil/mem"
    )
    
    func main() {}
    

    Expected behavior There isn't any messages about deprecation.

    Environment (please complete the following information):

    • [x] Mac OS: [paste the result of sw_vers and uname -a
    ProductName:	macOS
    ProductVersion:	12.0.1
    BuildVersion:	21A559
    
    Darwin MacBook-Pro.local 21.1.0 Darwin Kernel Version 21.1.0: Wed Oct 13 17:33:23 PDT 2021; root:xnu-8019.41.5~1/RELEASE_X86_64 x86_64
    
  • [windows]services: add windows service feature

    [windows]services: add windows service feature

    Hi, @shirou I write windows service package to implement like psutil win_services.

    usage:

    
    import (
    	"fmt"
    	"log"
    
    	"github.com/shirou/gopsutil/winservices"
    )
    
    func main() {
            name := "MySQL57"
    	srv, err := winservices.NewService(name)
    	if err != nil {
    		log.Fatalf("get service by name error, %s", err)
    	}
    	if err := srv.GetServiceDetail(); err != nil {
    		log.Fatalf("get service %s error, %s", name, err)
    	}
    
           services, err := winservices.ListServices()
    	if err != nil {
    		log.Fatal(err)
    	}
    }
    

    implement #524, please check it. I don't know how to write test code for this feature, can you tell me? thanks :)

  • processor, v3/processor (Win): fix slow cpuinfo on multisocket config

    processor, v3/processor (Win): fix slow cpuinfo on multisocket config

    updated win32_Processor struct to exclude (unused) LoadPercentage field. The loadpercentage takes linearly more time as the # of sockets increases. By default vSphere maps 1 vCPU to 1 socket, resulting in very poor performance when getting CPU info against, saying, 40 vCPU VM (basically 40 sockets as seen by the VM).

    Here is the before and after time comparison: printcpu-diff

    changes:

    for cpu: since Win32_Processor is a public struct, created a substruct named: Win32_ProcessorWithoutLoadPct for use in all queries without breaking any potential usage of the public api.

    for v3/cpu: since the struct now is private, simply removed LoadPercentage

  • iOS build error:

    iOS build error: "C source files not allowed when not using cgo or SWIG: iostat_darwin.c"

    Describe the bug I'm getting a "C source files not allowed when not using cgo or SWIG: iostat_darwin.c" error when compiling when trying to compile go-btfs which has a dependency on go-sutil. I need to use CGO so CGO=0 is not doable for me, issue is happening for arm64 and x86_64 as well.

    Exact output error:

    package github.com/bittorrent/go-btfs/cmd/btfs imports github.com/bittorrent/go-btfs/chain imports github.com/bittorrent/go-btfs/core/commands/storage/path imports github.com/shirou/gopsutil/v3/disk: C source files not allowed when not using cgo or SWIG: iostat_darwin.c make: *** [ios-arm64] Error 1

    To Reproduce

    v3.22.12

    	CGO_ENABLED=1 \
    	GOOS=darwin \
    	GOARCH=arm64 \
    	SDK=iphoneos \
    	SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
    	CC=$(PWD)/clangwrap.sh \
    	CGO_CFLAGS="-fembed-bitcode -Wno-undef-prefix" \
    	go build -buildmode=c-archive -tags ios -o $(IOS_OUT)/arm64.a .
    

    Expected behavior Compiling completed with no issues

    Environment (please complete the following information):

    • [ ] Windows: [paste the result of ver]

    • [ ] Linux: [paste contents of /etc/os-release and the result of uname -a]

    • [X] Mac OS: ProductName: macOS ProductVersion: 13.1 BuildVersion: 22C65 Darwin Simbads-MacBook-Air.local 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:04:44 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8103 arm64

    • [ ] FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]

    • [ ] OpenBSD: [paste the result of uname -a]

    Additional context [Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding go env] GO111MODULE="" GOARCH="arm64" GOBIN="" GOCACHE="/Users/simbadmarino/Library/Caches/go-build" GOENV="/Users/simbadmarino/Library/Application Support/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="arm64" GOHOSTOS="darwin" GOINSECURE="" GOMODCACHE="/Users/simbadmarino/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/simbadmarino/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64" GOVCS="" GOVERSION="go1.19.4" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/simbadmarino/Documents/btfs-sharedLib/go.mod" 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/89/7_dkrhfd345107kdvp3gk4p40000gn/T/go-build1188434045=/tmp/go-build -gno-record-gcc-switches -fno-common"

    MakeFile:

    	CGO_ENABLED=1 \
    	GOOS=darwin \
    	GOARCH=arm64 \
    	SDK=iphoneos \
    	SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk \
    	CC=$(PWD)/clangwrap.sh \
    	CGO_CFLAGS="-fembed-bitcode -Wno-undef-prefix" \
    	go build -buildmode=c-archive -tags ios -o $(IOS_OUT)/arm64.a .
    

    clangwrap.txt

    Any support is greatly appreciated. Thanks

  • [host] windows: use millisecond precision for BootTime()

    [host] windows: use millisecond precision for BootTime()

    Previously, system uptime is truncated to seconds, and then the subtraction from time.Now() is performed. Because uptime does not roll over to the next second at the same instant as time.Now(), then BootTime() ends up not being precise, and often varies by 1 second.

    This commit does the subtraction before truncating to seconds, which results in a significantly lower chance of variance in BootTime().

    Old behaviour before change:

    PS C:\Users\jefferbrecht\go\src\boottime> cat main.go
    package main
    import (
            "fmt"
            "syscall"
            "time"
            "github.com/shirou/gopsutil/v3/host"
            "golang.org/x/sys/windows"
    )
    var (
            kernel32DLL      = windows.NewLazyDLL("kernel32.dll")
            procGetTickCount = kernel32DLL.NewProc("GetTickCount64")
    )
    func main() {
            ticks, _, _ := syscall.Syscall(procGetTickCount.Addr(), 0, 0, 0, 0)
            boot, _ := host.BootTime()
            now := time.Now().Unix()
            fmt.Printf("%d\t%d\t%d\n", ticks, boot, now)
    }
    PS C:\Users\jefferbrecht\go\src\boottime> go build .
    PS C:\Users\jefferbrecht\go\src\boottime> for ($i = 0; $i -lt 5; $i++) { .\boottime.exe }
    GetTickCount()  host.BootTime() time.Now()
    374255953       1671094442      1671468697
    374255984       1671094442      1671468697
    374256000       1671094441      1671468697  <-- host.BootTime() rolls over
    374256031       1671094441      1671468697
    374256093       1671094441      1671468697
    

    New behaviour after change:

    PS C:\Users\jefferbrecht\go\src\boottime> for ($i = 0; $i -lt 5; $i++) { .\boottime.exe }
    GetTickCount()  host.BootTime() time.Now()
    374009953       1671094441      1671468451
    374009968       1671094441      1671468451
    374010000       1671094441      1671468451  <-- host.BootTime() does not roll over
    374010015       1671094441      1671468451
    374010046       1671094441      1671468451
    

    Note that there is still a chance for BootTime() to roll over e.g. if the true boot time's milliseconds portion is close to 0. There is not much to be done about this since we cannot get both GetTickCount and time.Now atomically at the same instant.

  • Partitions on Windows

    Partitions on Windows

    Describe the bug Getting a invalid memory address or null pointer difference error when running the following code.

    panic: runtime error: invalid memory address or nil pointer dereference
    [signal 0xc0000005 code=0x0 addr=0x20 pc=0xeaab8a]
    
    goroutine 1 [running]:
    github.com/shirou/gopsutil/v3/disk.PartitionsWithContext({0xc000046000?, 0xc0000c9f70?}, 0x69?)
            C:/Users/rtucker/go/pkg/mod/github.com/shirou/gopsutil/[email protected]/disk/disk_windows.go:107 +0x20a
    github.com/shirou/gopsutil/v3/disk.Partitions(...)
            C:/Users/rtucker/go/pkg/mod/github.com/shirou/gopsutil/[email protected]/disk/disk.go:77
    main.CalcDiskSpace()
            E:/Coding/Testing/Go/mxlookup/main.go:319 +0x29
    main.main()
    

    To Reproduce

    319 parts, _ := disk.Partitions(false)
    320 fmt.Println(parts)
    

    Expected behavior I expected it to return a list of the Partitions as the function does in older versions of the module. However in V3 I'm getting the above error.

    Environment (please complete the following information):

    • [ ] Windows: Windows 10 Build 1904
  • Windows error: gopsutil: unexpected processor queue length counter error, please file an issue on github: err

    Windows error: gopsutil: unexpected processor queue length counter error, please file an issue on github: err

    Describe the bug

    print the error information

    gopsutil: unexpected processor queue length counter error, please file an issue on github: err
    

    To Reproduce

    // paste example code reproducing the bug you are reporting
    

    I am not sure what api cause this error

    Expected behavior

    It should works without any error information.

    Environment (please complete the following information):

    • [x] Windows: [paste the result of ver]
    • [ ] Linux: [paste contents of /etc/os-release and the result of uname -a]
    • [ ] Mac OS: [paste the result of sw_vers and uname -a
    • [ ] FreeBSD: [paste the result of freebsd-version -k -r -u and uname -a]
    • [ ] OpenBSD: [paste the result of uname -a]

    Additional context [Cross-compiling? Paste the command you are using to cross-compile and the result of the corresponding go env]

    set GO111MODULE=
    set GOARCH=amd64
    set GOBIN=
    set GOCACHE=C:\Users\Admin\AppData\Local\go-build
    set GOENV=C:\Users\Admin\AppData\Roaming\go\env  
    set GOEXE=.exe
    set GOEXPERIMENT=
    set GOFLAGS=
    set GOHOSTARCH=amd64
    set GOHOSTOS=windows
    set GOINSECURE=
    set GOMODCACHE=C:\Users\Admin\go\pkg\mod
    set GONOPROXY=
    set GONOSUMDB=
    set GOOS=windows
    set GOPATH=C:\Users\Admin\go
    set GOPRIVATE=
    set GOPROXY=https://proxy.golang.com.cn,direct   
    set GOROOT=C:\Program Files\Go
    set GOSUMDB=sum.golang.org
    set GOTMPDIR=
    set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
    set GOVCS=
    set GOVERSION=go1.19.3
    set GCCGO=gccgo
    set GOAMD64=v1
    set AR=ar
    set CC=gcc
    set CXX=g++
    set CGO_ENABLED=1
    set GOMOD=C:\Users\Admin\go\xx\go.mod
    set GOWORK=
    set CGO_CFLAGS=-g -O2
    set CGO_CPPFLAGS=
    set CGO_CXXFLAGS=-g -O2
    set CGO_FFLAGS=-g -O2
    set CGO_LDFLAGS=-g -O2
    set PKG_CONFIG=pkg-config
    set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=C:\Users\Admin\AppData\Local\Temp\go-build2193561186=/tmp/go-build -gno-record-gcc-switches
    PS C:\Users\Admin\go\src\xxx>
    

    截屏2022-11-18 22 06 25

    If need any additional information, please let me known.

  • Initial support for NetBSD

    Initial support for NetBSD

    These two commits will hopefully help bring support for NetBSD to the project. I have not been able to verify if these changes are correct yet ("go test" did not yield anything apparently useful). Please review before merging, and do so only if you feel like it is not expected to break anything new.

    For these changes, I have simply copied the OpenBSD files as NetBSD, as the two systems are usually very close to one another. As such I think at least some things should work once the module is confirmed to build.

Belajar Golang Install Golang

Golang belajar Golang Install Golang = download di https://golang.org/dl/ = pilih yg Zip = extract file zipnya = buka foldernya - copy folder go = pas

Nov 15, 2021
Golang-module-references - A reference for how to setup a Golang project with modules - Task Management + Math Examples

Golang Module Project The purpose of this project is to act as a reference for setting up future Golang projects using modules. This project has a mat

Jan 2, 2022
Golang-echo-sample - Make an out-of-the-box backend based on golang-echo

Golang-echo-sample - Make an out-of-the-box backend based on golang-echo

Dec 31, 2021
Minimalistic, pluggable Golang evloop/timer handler with dependency-injection

Anagent Minimalistic, pluggable Golang evloop/timer handler with dependency-injection - based on codegangsta/inject - go-macaron/inject and chuckpresl

Sep 27, 2022
GoLang Library for Browser Capabilities Project

Browser Capabilities GoLang Project PHP has get_browser() function which tells what the user's browser is capable of. You can check original documenta

Sep 27, 2022
Golang counters for readers/writers

Datacounter Golang counters for readers/writers. Examples ReaderCounter buf := bytes.Buffer{} buf.Write(data) counter := datacounter.NewReaderCounter(

Oct 9, 2022
Golang beautify data display for Humans

Golang beautify data display for Humans English 简体中文 Install # Stable version go get -u -v gopkg.in/ffmt.v1 # Latest version go get -u -v github.com/

Dec 22, 2022
a generic object pool for golang

Go Commons Pool The Go Commons Pool is a generic object pool for Golang, direct rewrite from Apache Commons Pool. Features Support custom PooledObject

Jan 5, 2023
Resiliency patterns for golang

go-resiliency Resiliency patterns for golang. Based in part on Hystrix, Semian, and others. Currently implemented patterns include: circuit-breaker (i

Jan 3, 2023
Type-safe Prometheus metrics builder library for golang

gotoprom A Prometheus metrics builder gotoprom offers an easy to use declarative API with type-safe labels for building and using Prometheus metrics.

Dec 5, 2022
Simple licensing library for golang.

license-key A simple licensing library in Golang, that generates license files containing arbitrary data. Note that this implementation is quite basic

Dec 24, 2022
Some utilities for Persian language in Go (Golang)

persian Some utilities for Persian language in Go (Golang). Installation go get github.com/mavihq/persian API .ToPersianDigits Converts all English d

Oct 22, 2022
A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell.

shellwords A Golang library to manipulate strings according to the word parsing rules of the UNIX Bourne shell. Installation go get github.com/Wing924

Sep 27, 2022
A golang URL Shortener

url-shortener A golang URL Shortener with mysql support. Using Bijective conversion between natural numbers (IDs) and short strings Installation Using

Dec 10, 2022
:guardsman: A teeny tiny and somewhat opinionated generator for your next golang project

A Yeoman Golang Generator We are very sorry Gophers, but other names for the generator where taken, so we choose go-lang. But we have gocreate as an a

Sep 27, 2022
Flow-based and dataflow programming library for Go (golang)
Flow-based and dataflow programming library for Go (golang)

GoFlow - Dataflow and Flow-based programming library for Go (golang) Status of this branch (WIP) Warning: you are currently on v1 branch of GoFlow. v1

Dec 30, 2022
a Go (Golang) MusicBrainz WS2 client library - work in progress
a Go (Golang) MusicBrainz WS2 client library - work in progress

gomusicbrainz a Go (Golang) MusicBrainz WS2 client library - a work in progress. Current state Currently GoMusicBrainz provides methods to perform sea

Sep 28, 2022
Consistent hashing with bounded loads in Golang

consistent This library provides a consistent hashing function which simultaneously achieves both uniformity and consistency. For detailed information

Dec 29, 2022
Парсер технологического журнала, основанный на стеке технологий Golang goroutines + Redis + Elasticsearch.
Парсер технологического журнала, основанный на стеке технологий Golang goroutines + Redis + Elasticsearch.

go-techLog1C Парсер технологического журнала, основанный на стеке технологий Golang goroutines + Redis + Elasticsearch. Стек является кросс-платформен

Nov 30, 2022