Exemplo
Setting FlagSet.ParseErrorsWhitelist.UnknownFlags = true ignores unrecognized flags during parsing, but silently consumes the immediately following non-flag token as the unknown flag's value, removing it from Args().
sha256:922657434b0768a0eafcdc138f53352c18de04eed8a691e1eba5c1a138954b04
PUBLISHED
L3_CONTRACT_PASS
MIT-0
Evidência de execução
O ambiente declarado é separado das execuções assinadas para mostrar exatamente o que foi provado.
Base da evidênciaContrato assinado aprovado
Recibos de verificação1
Nível de verificaçãoL3_CONTRACT_PASS
Ambiente declarado
- Contexto de execução
- go
- Sistema operacional
- linux
- Arquitetura
- x64
- Runtime
- go
- Linguagem
- go
- Gerenciador de pacotes
- go
Ambientes das execuções de verificação
- Contexto de execução
- go 1.26
- Sistema operacional
- linux alpine · musl
- Arquitetura
- x64
- Runtime
- go 1.26
- Linguagem
- go
- Gerenciador de pacotes
- go
- Execução
- container · docker
CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17
Caso
- Objetivo
- Setting FlagSet.ParseErrorsWhitelist.UnknownFlags = true ignores unrecognized flags during parsing, but silently consumes the immediately following non-flag token as the unknown flag's value, removing it from Args(). HOW
- Pacotes
-
github.com/spf13/pflag 1.0.10
- Ambiente
- go
- Criado
- 2026-08-17T12:00:26Z
O que costuma-se supor
Enabling ParseErrorsWhitelist.UnknownFlags allows unrecognized flags to pass through without error while preserving all subsequent positional arguments in FlagSet.Args().
O autor da amostra registrou aqui o que um desenvolvedor ou um modelo esperaria. O contrato abaixo é o que de fato rodou.
Contrato
- When ParseErrorsWhitelist.UnknownFlags is true, FlagSet.Parse on unknown flags without an equals sign silently consumes the following non-flag argument as the flag value, leaving Args empty rather than preserving the positional argument.
- When ParseErrorsWhitelist.UnknownFlags is true and an unknown flag is provided with an explicit inline value via equals sign, the subsequent positional argument is preserved in Args.
- When ParseErrorsWhitelist.UnknownFlags is true and an unknown flag is followed by another flag starting with a dash, the subsequent flag is not swallowed and positional arguments are preserved.
- When ParseErrorsWhitelist.UnknownFlags is false by default, FlagSet.Parse returns an unknown flag error when encountering an unrecognized flag.
Arquivos
- NOTES.md
- csx.json
- go.mod
- go.sum
- pflag_config_test.go
Baixar o artefato de código-fonte (tar.gz)
Seeder de origem
csx-seed
Recibos de verificação
- go 1.26 · linux alpine/x64 · docker · CONTAINER_RUN · compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS · golang@1 · 2026-08-17 · ed25519:d91480838ac982c9