# Setting up Goland to compile plugins on Windows

**URL:** https://forum.heroiclabs.com/t/setting-up-goland-to-compile-plugins-on-windows/594
**Category:** Local Setup
**Tags:** getting-started
**Created:** [April 2, 2020, 11:12pm UTC](https://forum.heroiclabs.com/t/setting-up-goland-to-compile-plugins-on-windows/594 "2020-04-02T23:12:47Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![BeLuckyDaf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/beluckydaf/32/211_2.png) [@BeLuckyDaf](https://forum.heroiclabs.com/u/BeLuckyDaf)
#### Post date: [April 2, 2020, 11:12pm UTC](https://forum.heroiclabs.com/t/setting-up-goland-to-compile-plugins-on-windows/594/1 "2020-04-02T23:12:47Z")

</div>

Hi, I am just starting out using Nakama and I’ve been struggling trying to compile plugins on Windows, since Go does not support `-buildmode=plugin` on this OS. So I was trying to make the workflow better by setting up Goland for syntax highlighting and stuff.

But I could not make Go cross-compile correctly, I tried setting the GOOS environment variable to ‘linux’, but I think it’s not enough because it says:

`C:\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exec: "gcc": executable file not found in %PATH%`

So I think that I need to use linux toolchain to build it correctly, but no idea how to install it for Windows, asking for help.

As a workaround, I just go to WSL and compile it from there, but eh, I want it to be a one-button job 🙂

---

<div class="post-metadata">

### Author: ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)
#### Post date: [May 25, 2020, 7:57pm UTC](https://forum.heroiclabs.com/t/setting-up-goland-to-compile-plugins-on-windows/594/2 "2020-05-25T19:57:38Z")

</div>

Hey @BeLuckyDaf did you resolve you questions about using Go runtime plugins with Nakama?

---

<div class="post-metadata">

### Author: ![BeLuckyDaf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/beluckydaf/32/211_2.png) [@BeLuckyDaf](https://forum.heroiclabs.com/u/BeLuckyDaf)
#### Post date: [May 29, 2020, 3:22pm UTC](https://forum.heroiclabs.com/t/setting-up-goland-to-compile-plugins-on-windows/594/3 "2020-05-29T15:22:16Z")

</div>

Well, yeah, I’m just using WSL and a simple shell script to automate building modules.

---

<div class="post-metadata">

### Author: ![novabyte](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/novabyte/32/1324_2.png) [@novabyte](https://forum.heroiclabs.com/u/novabyte)
#### Post date: [May 30, 2020, 12:26pm UTC](https://forum.heroiclabs.com/t/setting-up-goland-to-compile-plugins-on-windows/594/4 "2020-05-30T12:26:00Z")

</div>

@BeLuckyDaf can you share the steps you use as a workflow as I think it will help other Windows developers. Thanks 🙏

---

<div class="post-metadata">

### Author: ![BeLuckyDaf](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.heroiclabs.com/beluckydaf/32/211_2.png) [@BeLuckyDaf](https://forum.heroiclabs.com/u/BeLuckyDaf)
#### Post date: [June 1, 2020, 8:05pm UTC](https://forum.heroiclabs.com/t/setting-up-goland-to-compile-plugins-on-windows/594/5 "2020-06-01T20:05:00Z")

</div>

# Prerequisites

1. Install Visual Studio Code to use with WSL: [https://code.visualstudio.com/](https://code.visualstudio.com/)  
a. Install the Remote WSL extension: [https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-wsl)  
b. Probably Golang extension wouldn’t hurt too: [https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go](https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go)
2. Install WSL: [https://docs.microsoft.com/en-us/windows/wsl/install-win10](https://docs.microsoft.com/en-us/windows/wsl/install-win10)
3. Install a distro for WSL from Microsoft Store, e.g. Ubuntu
4. Install the correct version of Go into WSL: [https://golang.org/doc/install#install](https://golang.org/doc/install#install)
5. Install CockroachDB: [https://www.cockroachlabs.com/docs/stable/install-cockroachdb-linux.html](https://www.cockroachlabs.com/docs/stable/install-cockroachdb-linux.html)

# Setting up Nakama & Cockroach

1. Make a directory for the local Nakama server

```bash
mkdir nakama-server
cd nakama-server

```

1. Download and extract Nakama binary

```bash
wget https://github.com/heroiclabs/nakama/releases/download/v2.12.0/nakama-2.12.0-linux-amd64.tar.gz
tar -xzvf nakama-2.12.0-linux-amd64.tar.gz
# here you might want to remove everything except for the binary itself

```

1. Create a directory for the local database & start it there

```bash
mkdir db
cd db
cockroach start-single-node --insecure
# now go for another terminal, leave the db working here

```

1. Start Nakama and make sure everything is fine

```bash
./nakama migrate up
./nakama
# if you see that everything went well, shut it down for now

```

# Setting up the project

1. Create your **go.mod** file. This is what it would look like if **MODULENAME** is the name of your server module

```auto
module MODULENAME

go 1.14

require (
	github.com/golang/protobuf v1.3.5
	github.com/heroiclabs/nakama-common v1.5.1
)

```

Now, it’s worth mentioning that vscode would probably try to suggest you to upgrade the version of protobuf. Don’t, or if you did, get it back to 1.3.5 (at this point).

1. Optionally, write a shell script for automatic module building and launching Nakama with it. This is super useful, because you’re gonna rebuild hundreds of times during the development and this is an easy and super quick way to do it, instead of manually copying and pasting your .so module.

```bash
export NAKAMA_RUNTIME_PATH=<path-to-where-you-want-you-data-stored>
export NAKAMA_PATH=<path-to-directory-with-nakama-executable>
export MY_NAKAMA_MODULE_NAME=<nakama-module-name>

# e.g. in my case it is
# export NAKAMA_RUNTIME_PATH=/home/beluc/nakama-server/
# export NAKAMA_PATH=/home/beluc/nakama-server/
# export MY_NAKAMA_MODULE_NAME=spacebattle

if (go build -buildmode=plugin -trimpath -o $NAKAMA_RUNTIME_PATH/data/modules/$MY_NAKAMA_MODULE_NAME.so) ; then 
    $NAKAMA_PATH/nakama migrate up
    $NAKAMA_PATH/nakama -runtime.path $NAKAMA_RUNTIME_PATH
fi

```

# Finally

Try it out on Heroic Labs’ sample Nakama module: [https://github.com/heroiclabs/nakama/tree/master/sample\_go\_module](https://github.com/heroiclabs/nakama/tree/master/sample_go_module)
