From e13efa2cb8f1e6625a7c8d238d5a490a3c889a12 Mon Sep 17 00:00:00 2001 From: Shirong Lu <73147033+happysnaker@users.noreply.github.com> Date: Fri, 3 Jul 2026 19:48:15 +0800 Subject: [PATCH] feat: add package-level SortFlags for convenience --- flag.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flag.go b/flag.go index ced8440a..b41294ed 100644 --- a/flag.go +++ b/flag.go @@ -1375,6 +1375,11 @@ func Parsed() bool { return CommandLine.Parsed() } +// SortFlags is the package-level indicator for whether CommandLine flags should be sorted. +// Set SortFlags = false to print flags in the order they were added. +// This is a convenience alias for CommandLine.SortFlags. +var SortFlags = &CommandLine.SortFlags + // CommandLine is the default set of command-line flags, parsed from os.Args. var CommandLine = NewFlagSet(os.Args[0], ExitOnError)