1

With halfdans advice, I was successfully able to use goinstall github.com/hoisie/web.go without any errors after installing git first. However, now when I try to compile the sample code given, go is not finding the web package. I get the error,

main.go:4: can't find import: web

On this code

package main

import (
    "web"
)

func hello(val string) string { return "hello " + val }

func main() {
    web.Get("/(.*)", hello)
    web.Run("0.0.0.0:9999")
}

Is there something special I need to do in order for it to recognize the package? I found the package source at $GOROOT/src/pkg/github.com/hoisie/web.go/web. I tried github.com/hoisie/web.go/web as the import and it still did not like that.

Community
  • 1
  • 1
Metropolis
  • 6,542
  • 19
  • 56
  • 86

2 Answers2

3

If you install web.go through goinstall, you need to do:

import "github.com/hoisie/web.go"

Goinstall is still an experimental system. It would be nice if you didn't have to include the full path.

marketer
  • 41,507
  • 11
  • 37
  • 40
  • Is there no way to alter this? Can I just move the files from github.com/hoisie/web.go to web/? Or would goinstall lose track of it if I do that? – Metropolis May 24 '10 at 00:13
  • 2
    You can just make a symbolic link using something like: `ln -s $GOROOT/src/pkg/github.com/hoisie/web.go ~/.node_libraries/` – Brian McKenna May 24 '10 at 00:59
  • Good idea Brian! I never think to make symbolic links when I know they make things much easier. – Metropolis May 24 '10 at 01:44
  • So is there no other way without messing things up then? – Metropolis May 24 '10 at 03:31
  • 1
    You can also go into $GOROOT/src/pkg/github.com/hoisie/web.go, and run a 'make install'. This will just install to the package 'web' – marketer May 25 '10 at 22:57
  • Sweet that worked! Thanks Hoisie......Before when I could not get goinstall working, I tried cloning the package with git, and running the make install on it, but I kept getting an error. Do you know why that would be? – Metropolis May 28 '10 at 01:16
2
import web "github.com/hoisie/web.go"
elimisteve
  • 1,771
  • 1
  • 18
  • 22