views:

46

answers:

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.

+3  A: 

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
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
You can just make a symbolic link using something like: `ln -s $GOROOT/src/pkg/github.com/hoisie/web.go ~/.node_libraries/`
Brian McKenna
Good idea Brian! I never think to make symbolic links when I know they make things much easier.
Metropolis
So is there no other way without messing things up then?
Metropolis
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
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
web.go should compile fine. What was the error?
marketer