|
| 1 | +# eolib-go |
| 2 | + |
| 3 | +Core library for writing Endless Online applications using the Go programming language. |
| 4 | + |
| 5 | +## Usage |
| 6 | + |
| 7 | +### Referencing the package |
| 8 | + |
| 9 | +The library may be referenced in a project via go get: |
| 10 | + |
| 11 | +``` |
| 12 | +go get https://github.com/ethanmoffat/eolib-go@v1.0.0 |
| 13 | +``` |
| 14 | + |
| 15 | +### Sample code |
| 16 | + |
| 17 | +A sample server skeleton using eolib-go is [available here](https://gist.github.com/ethanmoffat/95eed4ef0eeb524c8a505acb1bcbf956). |
| 18 | + |
| 19 | +## Development Environment |
| 20 | + |
| 21 | +### Installing go |
| 22 | + |
| 23 | +Development was done using go 1.20.5 on Ubuntu Linux. Development on Windows is untested. |
| 24 | + |
| 25 | +[gvm](https://github.com/moovweb/gvm) is recommended as a mechanism to manage installations of different versions of go. |
| 26 | + |
| 27 | +To set up gvm on Linux using bash: |
| 28 | +```bash |
| 29 | +bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer) |
| 30 | +source $HOME/.gvm/scripts/gvm |
| 31 | +``` |
| 32 | + |
| 33 | +The `source` command may be added to your `~/.bash_profile` so gvm is available in all login shells. |
| 34 | + |
| 35 | +```bash |
| 36 | +echo "source $HOME/.gvm/scripts/gvm" >> ~/.bash_profile |
| 37 | +``` |
| 38 | + |
| 39 | +Once gvm is installed and sourced, use the following commands to install and use go 1.20.5: |
| 40 | + |
| 41 | +```bash |
| 42 | +gvm install go1.20.5 -B |
| 43 | +gvm use go1.20.5 |
| 44 | +``` |
| 45 | + |
| 46 | +The `gvm use` command is required on each subsequent terminal or session in which `go` commands must be run. |
| 47 | + |
| 48 | +### VSCode setup |
| 49 | + |
| 50 | +If go is installed via gvm, you must update your `$GOROOT` variable to point at it, or VSCode won't be able to find the go binary. |
| 51 | + |
| 52 | +Get the path to the GOROOT via `go env`: |
| 53 | + |
| 54 | +```bash |
| 55 | +~ [ethan@BEASTMODE] $ gvm use go1.20.5 |
| 56 | +Now using version go1.20.5 |
| 57 | +~ [ethan@BEASTMODE] $ go env GOROOT |
| 58 | +/home/ethan/.gvm/gos/go1.20.5 |
| 59 | +``` |
| 60 | + |
| 61 | +In VSCode, search for the `GOROOT` setting and update the path to point at this version of go. |
| 62 | + |
| 63 | +Note that a gvm extension exists for VSCode but it is out of date and no longer functions properly. |
| 64 | + |
| 65 | +### Building the code |
| 66 | + |
| 67 | +A `Makefile` is provided to ease the process of building, testing, and code generation. Use `make help` to see all available targets. Running `make` by itself should be enough for most uses. `make test` is also available to run all tests. |
| 68 | + |
| 69 | +Building the library on Windows is left as an exercise to the reader. |
0 commit comments