oh-my-posh/website/docs/contributing/started.mdx

111 lines
3.2 KiB
Plaintext
Raw Normal View History

---
2022-04-20 09:43:59 -07:00
id: started
title: Get Started
sidebar_label: Get Started
---
2020-12-25 10:37:18 -08:00
## Install dependencies
### go
2021-03-17 10:34:09 -07:00
The codebase is in [go][go], meaning we need a working go setup before we can do anything else.
Have a look at the [go guide][go-started] to get up and running with go in no time!
2021-09-01 04:45:33 -07:00
:::caution
2022-03-20 23:17:33 -07:00
Oh My Posh needs at least go 1.18.
2021-03-17 10:34:09 -07:00
:::
### golangci-lint
To make sure we keep on writing quality code, [golang-ci lint][golang-ci-lint] is used to validate the changes.
Have a look at the [local installation guide][golang-ci-lint-local] to make sure you can validate this yourself as well.
2020-12-25 10:37:18 -08:00
## Get the source code
2020-12-29 00:13:56 -08:00
The source is hosted on [Github][omp]. When you want to contribute, create a [fork][gh-fork] so you can make changes in
2021-09-25 03:55:01 -07:00
your repository and create a pull request in the official Oh My Posh repository.
2020-12-25 10:37:18 -08:00
Clone your fork of Oh My Posh locally, replace `<user>` with your Github username.
2020-12-25 10:37:18 -08:00
```bash
2021-02-15 23:36:37 -08:00
git clone git@github.com:<user>/oh-my-posh.git
2020-12-25 10:37:18 -08:00
```
## Running tests
2020-12-25 11:48:14 -08:00
The go source code can be found in the `src/` directory, make sure to change to that one before continuing.
### Unit tests
```bash
2022-02-01 05:38:25 -08:00
go test -v ./...
```
### golangci-lint
```bash
golangci-lint run
```
## Building the app
The easiest way to validate your changes is to write tests. Unfortunately, as it's a visual tool, you'll want to validate
the changes by running the prompt in your shell as well. You can make use of go's `bin` folder which is usually added to
your path to add your own Oh My Posh binary to and immediately see the changes appear in your shell.
```bash
go build -o $GOPATH/bin/oh-my-posh
```
2020-12-29 00:13:56 -08:00
## Get an editor
2022-05-12 22:54:59 -07:00
A default config(.vscode folder) for [Visual Studio Code][code] is available in the repo:
2020-12-29 00:13:56 -08:00
- golangci-lint is configured as the default linter.
- Recommended extensions available for a smooth bootstrap.
2021-02-03 23:38:55 -08:00
![recommended extensions](/img/recommended_extensions.png "Recommended extensions" )
2020-12-29 00:13:56 -08:00
- Default run and debug configurations available.
Once the extensions are installed:
- Debug can be started by hitting F5.
- All tests can be run using the Test explorer.
### Extra tips
#### Configure Delve in VS Code
2022-05-12 22:54:59 -07:00
[Delve][delve] config is restrictive by default(string limit especially). You can expand some limits in VS Code(`settings.json` or directly in `launch.json`):
```
"go.delveConfig": {
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 3,
"maxStringLen": 400,
"maxArrayValues": 400,
"maxStructFields": -1
},
"apiVersion": 2,
"showGlobalVariables": false
}
```
## Up Next
With everything set up, you're ready to start making changes and create your first [PR][gh-pr]!
[go]: https://golang.org
[go-started]: https://golang.org/doc/install
[golang-ci-lint]: https://golangci-lint.run
[golang-ci-lint-local]: https://golangci-lint.run/usage/install/#local-installation
[go-bindata]: https://github.com/kevinburke/go-bindata/
[go-global]: https://github.com/golang/go/issues/40276
2021-02-15 23:36:37 -08:00
[pr-go-mod]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/.github/workflows/gomod.yml
[gh-pr]: https://github.com/JanDeDobbeleer/oh-my-posh/pulls
[omp]: https://github.com/JanDeDobbeleer/oh-my-posh
2020-12-25 10:37:18 -08:00
[gh-fork]: https://guides.github.com/activities/forking/
2022-05-12 22:54:59 -07:00
[code]: https://code.visualstudio.com
[delve]: https://github.com/go-delve/delve