github.com/jonsyu1/godel@v0.0.0-20171017211503-64567a0cf169/docs/Generate-IDE-project.md (about)

     1  Summary
     2  -------
     3  `./godelw idea gogland` generates the project files necessary to load a project in [Gogland](https://www.jetbrains.com/go/)
     4  with "File Watchers" plugin configuration that runs `./godelw format` on modified files on save.
     5  
     6  Tutorial start state
     7  --------------------
     8  
     9  * `$GOPATH/src/github.com/nmiyake/echgo` exists and is the working directory
    10  * Project contains `godel` and `godelw`
    11  * Project contains `main.go`
    12  
    13  ([Link](https://github.com/nmiyake/echgo/tree/9e77ec4885591f5a4fd95b550da729a004e7a04a))
    14  
    15  Create Gogland project file
    16  ---------------------------
    17  
    18  Gogland is a nice full-featured Go IDE with many convenient features, and gödel makes it easy to generate Gogland
    19  project files for a project to start development on it with minimal overhead.
    20  
    21  Run the following command to generate the IDE files:
    22  
    23  ```
    24  ➜ ./godelw idea gogland
    25  ```
    26  
    27  This generates an `.iml` and `.ipr` file for the project. The generated `.ipr` file can be opened in Gogland to reveal
    28  that the project has been set up properly:
    29  
    30  ![download](images/tutorial/ide_gogland.png)
    31  
    32  We do not want to commit the Gogland files to the repository, so we will create and commit a `.gitigore` file that
    33  ignores these files:
    34  
    35  ```
    36  ➜ echo '*.iml
    37  *.ipr
    38  *.iws' > .gitignore
    39  ➜ git add .gitignore
    40  ➜ git commit -m "Add .gitignore file"
    41  [master 0c815bf] Add .gitignore file
    42   1 file changed, 3 insertions(+)
    43   create mode 100644 .gitignore
    44  ➜ git status
    45  On branch master
    46  nothing to commit, working directory clean
    47  ```
    48  
    49  Tutorial end state
    50  ------------------
    51  
    52  * `$GOPATH/src/github.com/nmiyake/echgo` exists and is the working directory
    53  * Project contains `godel` and `godelw`
    54  * Project contains `main.go`
    55  * Project contains `.gitignore` that ignores IDEA files
    56  
    57  ([Link](https://github.com/nmiyake/echgo/tree/0c815bfd02711336f5ec0124377c95829667928a))
    58  
    59  Tutorial next step
    60  ------------------
    61  
    62  [Format Go files](https://github.com/palantir/godel/wiki/Format)
    63  
    64  More
    65  ----
    66  
    67  ### File Watchers plugin
    68  
    69  The project file generated by gödel configures the ["File Watchers" plugin](https://plugins.jetbrains.com/plugin/7177-file-watchers)
    70  to run the `./godelw format` task to automatically format modified files on save. It is recommended that you install the
    71  "File Watchers" plugin in Gogland to support this workflow. The "File Watchers" plugin is global to Gogland, so once it
    72  is installed all projects can take advantage of it.
    73  
    74  Verify that the "File Watchers" plugin is installed and working by doing the following:
    75  
    76  * Open `main.go`, remove line 6 (the newline preceding `func main() {`) and save the file
    77  
    78  If the "File Watchers" plugin is installed and the configuration generated by the `idea` task is working properly, then
    79  the newline should automatically be re-added on save. This is because the Gogland project generated by gödel is
    80  configured to run `./godelw format` on all modified files on save.