cli arguments
This commit is contained in:
parent
e5ae825999
commit
7d9228f759
@ -62,7 +62,7 @@ Epoch
|
|||||||
Директории (Directories)
|
Директории (Directories)
|
||||||
Временные файлы и директории (Temporary Files and Directories)
|
Временные файлы и директории (Temporary Files and Directories)
|
||||||
Тестирование (Testing)
|
Тестирование (Testing)
|
||||||
Command-Line Arguments
|
Аргументы командной строки (Command-Line Arguments)
|
||||||
Command-Line Flags
|
Command-Line Flags
|
||||||
Command-Line Subcommands
|
Command-Line Subcommands
|
||||||
Environment Variables
|
Environment Variables
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
// [_Command-line arguments_](http://en.wikipedia.org/wiki/Command-line_interface#Arguments)
|
// [_Аргументы командной строки_](http://en.wikipedia.org/wiki/Command-line_interface#Arguments)
|
||||||
// are a common way to parameterize execution of programs.
|
// являются распространенным способом параметризации
|
||||||
// For example, `go run hello.go` uses `run` and
|
// выполнения программ. Например, `go run hello.go`
|
||||||
// `hello.go` arguments to the `go` program.
|
// использует аргументы `run` и `hello.go` для программы
|
||||||
|
// `go`.
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
@ -12,14 +13,16 @@ import (
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// `os.Args` provides access to raw command-line
|
// `os.Args` предоставляет доступ к необработанным
|
||||||
// arguments. Note that the first value in this slice
|
// аргументам командной строки. Обратите внимание,
|
||||||
// is the path to the program, and `os.Args[1:]`
|
// что первое значение в этом срезе - это путь к
|
||||||
// holds the arguments to the program.
|
// программе, а os.Args [1:] содержит аргументы
|
||||||
|
// программы.
|
||||||
argsWithProg := os.Args
|
argsWithProg := os.Args
|
||||||
argsWithoutProg := os.Args[1:]
|
argsWithoutProg := os.Args[1:]
|
||||||
|
|
||||||
// You can get individual args with normal indexing.
|
// Вы можете получить отдельные аргументы с
|
||||||
|
// обычной индексацией.
|
||||||
arg := os.Args[3]
|
arg := os.Args[3]
|
||||||
|
|
||||||
fmt.Println(argsWithProg)
|
fmt.Println(argsWithProg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user