The following multi-line command
mkdir example
cd example
go mod init github.com/yuk1ty/example
git init
touch main.go
# edit Go code with your favourite editors
is shortened as below by using readygo
readygo -p github.com/yuk1ty/example
Use go install
.
go install github.com/yuk1ty/readygo@latest
readygo
has the following options:
--dir-name
or-n
: Name for the directory which is created byreadygo
. This option can be omitted.--module-path
or-p
: Module path forgo mod init
command.--layout
or-l
: Directory layout style. You can choose Standard Go Project Layout style (standard
) or empty style (default
). This option can be omitted. The default value isdefault
, creates an empty directory.
readygo --help
Usage:
readygo [flags]
Flags:
-n, --dir-name string Define the directory name of your project. This can be omitted. If you do so, the name will be extracted from its package name.
-h, --help help for readygo
-l, --layout default Define your project layout. You can choose default or `standard`. If you omit this option, the value becomes `default`. (default "default")
-p, --module-path string Define your module path. This is used for go mod init [module path].
readygo --dir-name newprj --module-path github.com/yuk1ty/example
generates
ls -a --tree --level 1 newprj
newprj
├── .git
├── .gitignore
├── go.mod
└── main.go
and its go.mod
is to be as below:
module github.com/yuk1ty/example
go 1.18
readygo -n example -p github.com/yuk1ty/example -l standard
generates
ls -a --tree --level 1 example
example
├── .git
├── .gitignore
├── cmd
├── go.mod
├── internal
├── main.go
└── pkg
readygo -p github.com/yuk1ty/example
generates
ls -a --tree --level 1 example
example
├── .git
├── .gitignore
├── go.mod
└── main.go
The following one (illustrates the case that is not starting with github.com/username
) works fine as well.
readygo -p example
generates
ls -a --tree --level 1 example
example
├── .git
├── .gitignore
├── go.mod
└── main.go