go.flag 1.23.1.6

dotnet add package go.flag --version 1.23.1.6
                    
NuGet\Install-Package go.flag -Version 1.23.1.6
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="go.flag" Version="1.23.1.6" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="go.flag" Version="1.23.1.6" />
                    
Directory.Packages.props
<PackageReference Include="go.flag" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add go.flag --version 1.23.1.6
                    
#r "nuget: go.flag, 1.23.1.6"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package go.flag@1.23.1.6
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=go.flag&version=1.23.1.6
                    
Install as a Cake Addin
#tool nuget:?package=go.flag&version=1.23.1.6
                    
Install as a Cake Tool

go.flag

C# package converted from the Go standard library by go2cs.

Tests Docs Source Source

Package flag implements command-line flag parsing.

Usage

Define flags using flag.String, [Bool], [Int], etc.

This declares an integer flag, -n, stored in the pointer nFlag, with type *int:

import "flag"
var nFlag = flag.Int("n", 1234, "help message for flag n")

If you like, you can bind the flag to a variable using the Var() functions.

var flagvar int
func init() {
	flag.IntVar(&flagvar, "flagname", 1234, "help message for flagname")
}

Or you can create custom flags that satisfy the Value interface (with pointer receivers) and couple them to flag parsing by

flag.Var(&flagVal, "name", "help message for flagname")

For such flags, the default value is just the initial value of the variable.

After all flags are defined, call

flag.Parse()

to parse the command line into the defined flags.

Flags may then be used directly. If you're using the flags themselves, they are all pointers; if you bind to variables, they're values.

fmt.Println("ip has value ", *ip)
fmt.Println("flagvar has value ", flagvar)

After parsing, the arguments following the flags are available as the slice flag.Args or individually as flag.Arg(i). The arguments are indexed from 0 through flag.NArg-1.

Command line flag syntax

The following forms are permitted:

-flag
--flag   // double dashes are also permitted
-flag=x
-flag x  // non-boolean flags only

One or two dashes may be used; they are equivalent. The last form is not permitted for boolean flags because the meaning of the command

cmd -x *

where * is a Unix shell wildcard, will change if there is a file called 0, false, etc. You must use the -flag=false form to turn off a boolean flag.

Flag parsing stops just before the first non-flag argument ("-" is a non-flag argument) or after the terminator "--".

Integer flags accept 1234, 0664, 0x1234 and may be negative. Boolean flags may be:

1, 0, t, f, T, F, true, false, TRUE, FALSE, True, False

Duration flags accept any input valid for time.ParseDuration.

The default set of command-line flags is controlled by top-level functions. The [FlagSet] type allows one to define independent sets of flags, such as to implement subcommands in a command-line interface. The methods of [FlagSet] are analogous to the top-level functions for the command-line flag set.


Copyright 2009 The Go Authors. All rights reserved. This C# package is converted from Go standard library source; use of that source is governed by a BSD-style license that can be found in the LICENSE file. The go2cs conversion itself is distributed under the MIT license.

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on go.flag:

Package Downloads
go.testing.quick

testing.quick (net9.0 - Release) -- C# project converted from Go source

go.net.http.httptest

net.http.httptest (net9.0 - Release) -- C# project converted from Go source

go.internal.testenv

internal.testenv (net9.0 - Release) -- C# project converted from Go source

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.23.1.6 7 8/11/2026
1.23.1.5 100 8/9/2026
1.23.1.4 114 8/8/2026
1.23.1.3 117 8/4/2026
1.23.1.2 144 7/27/2026
1.23.1.1 203 7/14/2026