github.com/yuk1ty/readygo@v0.2.1-0.20220502041311-7a0cf7a1a1aa/README.md (about)

     1  # readygo
     2  
     3  The following multi-line command
     4  
     5  ```shell
     6  mkdir example
     7  cd example
     8  go mod init github.com/yuk1ty/example
     9  git init
    10  touch main.go
    11  # edit Go code with your favourite editors
    12  ```
    13  
    14  is shortened as below by using `readygo`
    15  
    16  ```shell
    17  readygo -p github.com/yuk1ty/example
    18  ```
    19  
    20  ## Getting started
    21  
    22  Use `go install`.
    23  
    24  ```
    25  go install github.com/yuk1ty/readygo@latest
    26  ```
    27  
    28  ## How to use
    29  
    30  ### Basic usage
    31  
    32  `readygo` has the following options:
    33  
    34  - `--dir-name` or `-n`: Name for the directory which is created by `readygo`. This option can be omitted.
    35  - `--module-path` or `-p`: Module path for `go mod init` command.
    36  - `--layout` or `-l`: Directory layout style. You can choose [Standard Go Project Layout](https://github.com/golang-standards/project-layout) style (`standard`) or empty style (`default`). This option can be omitted. The default value is `default`, creates an empty directory.
    37  
    38  ### Examples
    39  
    40  ```
    41  readygo --help
    42  Usage:
    43    readygo [flags]
    44  
    45  Flags:
    46    -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.
    47    -h, --help                 help for readygo
    48    -l, --layout default       Define your project layout. You can choose default or `standard`. If you omit this option, the value becomes `default`. (default "default")
    49    -p, --module-path string   Define your module path. This is used for go mod init [module path].
    50  ```
    51  
    52  #### Full
    53  
    54  ```shell
    55  readygo --dir-name newprj --module-path github.com/yuk1ty/example
    56  ```
    57  
    58  generates
    59  
    60  ```shell
    61  ls -a --tree --level 1 newprj
    62  newprj
    63  ├── .git
    64  ├── .gitignore
    65  ├── go.mod
    66  └── main.go
    67  ```
    68  
    69  and its `go.mod` is to be as below:
    70  
    71  ```shell
    72  module github.com/yuk1ty/example
    73  
    74  go 1.18
    75  ```
    76  
    77  #### With layout style
    78  
    79  ```shell
    80  readygo -n example -p github.com/yuk1ty/example -l standard
    81  ```
    82  
    83  generates
    84  
    85  ```shell
    86  ls -a --tree --level 1 example
    87  example
    88  ├── .git
    89  ├── .gitignore
    90  ├── cmd
    91  ├── go.mod
    92  ├── internal
    93  ├── main.go
    94  └── pkg
    95  ```
    96  
    97  #### Omit `--dir-name(-n)`
    98  
    99  ```shell
   100  readygo -p github.com/yuk1ty/example
   101  ```
   102  
   103  generates
   104  
   105  ```shell
   106  ls -a --tree --level 1 example
   107  example
   108  ├── .git
   109  ├── .gitignore
   110  ├── go.mod
   111  └── main.go
   112  ```
   113  
   114  The following one (illustrates the case that is not starting with `github.com/username`) works fine as well.
   115  
   116  ```shell
   117  readygo -p example
   118  ```
   119  
   120  generates
   121  
   122  ```shell
   123  ls -a --tree --level 1 example
   124  example
   125  ├── .git
   126  ├── .gitignore
   127  ├── go.mod
   128  └── main.go
   129  ```