From b72edd12e5e7a2b2dda0cb3e2e2fa360e9386743 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Mon, 6 Mar 2023 14:49:45 -0500 Subject: [PATCH] gopls/internal/lsp/filecache: GOPLS_CACHE -> GOPLSCACHE The go command doesn't use underscores in environment variables, so nor should gopls. Also, document the curious phenomenon that du -sh reports a larger figure than the budget even when the GC is working. Change-Id: I156255dc528c7bd700cb76545e9d60e2c4d153fc Reviewed-on: https://go-review.googlesource.com/c/tools/+/473676 Run-TryBot: Alan Donovan Reviewed-by: Robert Findley TryBot-Result: Gopher Robot gopls-CI: kokoro --- gopls/internal/lsp/filecache/filecache.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gopls/internal/lsp/filecache/filecache.go b/gopls/internal/lsp/filecache/filecache.go index f48eed9038a..a51098579b3 100644 --- a/gopls/internal/lsp/filecache/filecache.go +++ b/gopls/internal/lsp/filecache/filecache.go @@ -13,6 +13,9 @@ // // The space budget of the cache can be controlled by [SetBudget]. // Cache entries may be evicted at any time or in any order. +// Note that "du -sh $GOPLSCACHE" may report a disk usage +// figure that is rather larger (e.g. 50%) than the budget because +// it rounds up partial disk blocks. // // The Get and Set operations are concurrency-safe. package filecache @@ -161,7 +164,7 @@ func filename(kind string, key [32]byte) string { func getCacheDir() string { cacheDirOnce.Do(func() { // Use user's preferred cache directory. - userDir := os.Getenv("GOPLS_CACHE") + userDir := os.Getenv("GOPLSCACHE") if userDir == "" { var err error userDir, err = os.UserCacheDir()