From b095a40ba34df4c0ce8fb9e8f1b68fef2b336956 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 23 Jan 2025 01:04:38 +0700 Subject: lib/debug: remove the global Value variable Using global variable inside one package is a mistake. If, for example, package X set debug.Value to 1, another packages that does need to be debugged will print unnecessary log messages. --- lib/debug/debug.go | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/lib/debug/debug.go b/lib/debug/debug.go index df3cf9d8..790db417 100644 --- a/lib/debug/debug.go +++ b/lib/debug/debug.go @@ -2,24 +2,6 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// Package debug provide global debug variable, initialized through -// environment variable "DEBUG" or directly. +// Package debug provide library for profiling Go program. +// Its a wrapper for standard [runtime] and [runtime/pprof] packages. package debug - -import ( - "os" - "strconv" -) - -var ( - // Value contains DEBUG value from environment. - Value = 0 -) - -// init initialize debug from system environment. -func init() { - v := os.Getenv("DEBUG") - if len(v) > 0 { - Value, _ = strconv.Atoi(v) - } -} -- cgit v1.3