From ccb11cf45e4e253e0a2d01cb0699f70151a53f3d Mon Sep 17 00:00:00 2001 From: Steve Zhang Date: Mon, 28 Nov 2022 22:30:09 -0700 Subject: [PATCH] reuse the context.Context instead of creating a new Context --- mem/mem_solaris.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mem/mem_solaris.go b/mem/mem_solaris.go index d22cf0b..c911267 100644 --- a/mem/mem_solaris.go +++ b/mem/mem_solaris.go @@ -35,7 +35,7 @@ func VirtualMemoryWithContext(ctx context.Context) (*VirtualMemoryStat, error) { return nil, err } result.Total = cap - freemem, err := globalZoneFreeMemory() + freemem, err := globalZoneFreeMemory(ctx) if err != nil { return nil, err } @@ -93,8 +93,7 @@ func globalZoneMemoryCapacity() (uint64, error) { return totalMB * 1024 * 1024, nil } -func globalZoneFreeMemory() (uint64, error) { - ctx := context.Background() +func globalZoneFreeMemory(ctx context.Context) (uint64, error) { output, err := invoke.CommandWithContext(ctx, "pagesize") if err != nil { return 0, err