From 9afa0745ed20c325f149b49167ff1bffcae916bd Mon Sep 17 00:00:00 2001 From: Mritunjay Kumar Sharma Date: Thu, 30 Dec 2021 17:47:48 +0530 Subject: [PATCH] docs: Added some deprecated parts in migrating to v2 (#1319) Co-authored-by: Robert Liebowitz --- docs/migrate-v1-to-v2.md | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/docs/migrate-v1-to-v2.md b/docs/migrate-v1-to-v2.md index 0186746..15c509f 100644 --- a/docs/migrate-v1-to-v2.md +++ b/docs/migrate-v1-to-v2.md @@ -181,6 +181,48 @@ Compiler messages you might see: cannot use c (type *cli.Command) as type cli.Command in append ``` +# GlobalString, GlobalBool and its likes are deprecated + +Use simply `String` instead of `GlobalString`, `Bool` instead of `GlobalBool` + +# BoolTFlag and BoolT are deprecated + +BoolTFlag was a Bool Flag with its default value set to true and BoolT was used to find any BoolTFlag used locally, so both are deprecated. + +* OLD: + +```go +cli.BoolTFlag{ + Name: FlagName, + Usage: FlagUsage, + EnvVar: "FLAG_ENV_VAR", +} +``` +* NEW: +```go +cli.BoolFlag{ + Name: FlagName, + Value: true, + Usage: FlagUsage, + EnvVar: "FLAG_ENV_VAR", +} +``` + + +# &cli.StringSlice{""} replaced with cli.NewStringSlice("") + +Example: + +* OLD: + +```go +Value: &cli.StringSlice{""}, +``` +* NEW: +```go +Value: cli.NewStringSlice(""), +} +``` # Replace deprecated functions `cli.NewExitError()` is deprecated. Use `cli.Exit()` instead. ([Staticcheck](https://staticcheck.io/) detects this automatically and recommends replacement code.)