github.com/prebid/prebid-server/v2@v2.18.0/devcontainer.md (about) 1 2 ### vscode in-container development 3 4 The quickest way to get up and running with PBS-Go development in a reproducible environment isolated 5 from your host OS is by loading the repository in a [Docker](https://docs.docker.com/get-docker/) 6 container under [Visual Studio Code](https://code.visualstudio.com/). 7 8 This covers installing Go and necessary IDE plugins for Golang editing and debugging, and is 9 all automated via the VSCode [.devcontainer](.devcontainer/) configuration. See 10 [VSCode Remote Containers](https://code.visualstudio.com/docs/remote/containers) for more 11 details about how to customize. 12 13 #### Setup 14 15 Install: 16 17 - [Docker](https://docs.docker.com/get-docker/) 18 - [Visual Studio Code](https://code.visualstudio.com/) 19 - [VSCode Remote Development Extension Pack](https://aka.ms/vscode-remote/download/extension) 20 21 Then: 22 23 - start VSCode and open repository 24 - accept VSCode suggestion to _reopen in container_ 25 - VSCode will build a new container and install the IDE support and extensions in it 26 27 Optionally, to use your github ssh key for accessing non-public GitHub repositories: 28 - Method 1: add your github ssh key to agent. This is needed after each OS restart. 29 ```sh 30 ssh-add ~/.ssh/id_rsa # or your ssh key for github 31 ``` 32 - Method 2: map your ~/.ssh (or just the key) as a docker volume in .devcontainer.json 33 34 Feel free to customize .devcontainer.json if needed. You can add preset environment variables, 35 other vscode extensions to preload and additional volume mounts. 36 37 #### Starting PBS-Go 38 39 - `Shift`-`Cmd`-`D` or `Run` icon brings up the `Launch prebid-server` panel with interactive 40 debugger. Breakpoints can be set to stop execution. 41 - CTRL-`\`` opens the terminal to start prebid-server non-interactively 42 ```sh 43 go run main.go --alsologtostderr 44 ``` 45 - Create a pbs.yaml file if neccessary, with configuration overrides. 46 47 #### Testing 48 49 - Open any `*_test.go` file in editor 50 - Individual test functions can be run directly by clicking the `run test`/`debug test` annotation 51 above each test function. 52 - At the top of the file you can see `run package tests | run file tests` 53 - TIP: use `run package tests` at the top of the test file to quickly check code coverage: 54 the open editors for files in the tested package will have lines highlighted in green (covered) 55 and red (not covered) 56 - CTRL-`\`` opens the terminal to run the test suite 57 ```sh 58 ./validate.sh 59 ``` 60 61 #### Editing 62 - Style, imports are automatically updated on save. 63 - Editor can suggest correct names and 64 65 - Remote container commands popup by clicking on _Dev Container: Go_ at bottom left 66 - `F1` -> type _rebuild container_ to restart with a fresh container 67 - `F1` -> `^`-`\`` to toggle terminal