github.com/aretext/aretext@v1.3.0/DEVELOPING.md (about) 1 Developing 2 ========== 3 4 Setup 5 ----- 6 7 To build aretext, you will first need to [install go](https://golang.org/doc/install). 8 9 Next, install development tools: 10 11 ``` 12 make install-devtools 13 ``` 14 15 Building and Testing 16 -------------------- 17 18 To build aretext, format code, and run tests: 19 20 ``` 21 make 22 ``` 23 24 To only run tests: 25 26 ``` 27 make test 28 ``` 29 30 To format Go and Markdown files: 31 32 ``` 33 make fmt 34 ``` 35 36 Some files in the project are created by [go generate](https://go.dev/blog/generate) and checked into the git repository. This includes the state machine compiled from commands in [input/commands.go](input/commands.go). If you add a new command there, you should regenerate the state machine by running: 37 38 ``` 39 make generate 40 ``` 41 42 Please see the [Makefile](Makefile) for all available targets. 43 44 Logging 45 ------- 46 47 You can tell aretext to log debug information to a file like this: 48 49 ``` 50 aretext -log debug.log 51 ``` 52 53 You can then tail the log file in a separate terminal session to see what aretext is doing: 54 55 ``` 56 tail -f debug.log 57 ``` 58 59 Debugging 60 --------- 61 62 First, you will need to [install dlv](https://github.com/go-delve/delve/tree/master/Documentation/installation). 63 64 Then build aretext with debug symbols: 65 66 ``` 67 make build-debug 68 ``` 69 70 You can then start aretext and attach a debugger: 71 72 ``` 73 # Start aretext in one terminal. 74 ./aretext 75 76 # Switch to another terminal and attach a debugger. 77 # If there are multiple aretext processes running, 78 # replace `pgrep aretext` with the exact process ID. 79 dlv attach `pgrep aretext` 80 ``` 81 82 Profiling 83 --------- 84 85 You can tell aretext to profile its CPU usage like this: 86 87 ``` 88 aretext -cpuprofile cpu.prof 89 ``` 90 91 This will create a [pprof](https://pkg.go.dev/runtime/pprof) profile that you can analyze using `go tool pprof cpu.prof`