0

I'm trying to write a webapp with Go/App Engine and I'm using windows for my dev machine. When I try to break my app into modules (main, models, ...), and try to use relative path imports like

import './models'

I get an error saying that ':' is an illegal character in path. Windows uses Drive:\Path syntax for path, and the golang team seem to have refused to add ':' to the set of allowed characters in go path.

How do I write multi-module applications with Go on windows?

jz87
  • 9,199
  • 10
  • 37
  • 42
  • This may help - http://stackoverflow.com/questions/15049903/how-to-use-custom-packages-in-golang – Elad Jan 08 '17 at 15:14
  • don t use relative import paths, use ~~ `absolute_path_to_module.substr(len($GOPATH/src))` as your import path. May [this](https://github.com/mh-cbon/go-get-started) helps somehow as its not based on windows. –  Jan 08 '17 at 19:40

1 Answers1

2

How do you import relative module paths in windows for golang?

The simplest answer is don't use relative paths. These will cause you trouble in the long run and are frowned upon in general. The are only used is very special cases normally.

How do I write multi-module applications with Go on windows?

You need to set your GOPATH if you are writing multi module projects.

It seems like a pain at first, but it will enable your code to be go get-able if you want.

You can't use quite a few features of Go unless you are working in a GOPATH (like vendoring).

Nick Craig-Wood
  • 52,955
  • 12
  • 126
  • 132