go - Golang on OpenShift, I can't find local module -


i want use openshift test environment golang applications.

i made test application:

myproj/ ------web.go ------/mylib/ -------------mylib.go 

web.go standard openshift file:

package main  import (     "fmt"     "net/http"     "os"     "runtime"     "./mylib" )  func main() {     http.handlefunc("/", hello)     bind := fmt.sprintf("%s:%s", os.getenv("host"), os.getenv("port"))     fmt.printf("listening on %s...", bind)     err := http.listenandserve(bind, nil)     if err != nil {         panic(err)     } }  func hello(res http.responsewriter, req *http.request) {     str := mylib.lib();     fmt.fprintf(res, "hello, %s %s", str, runtime.version()) } 

and created "mylib"

package mylib  func lib() string {     return "world" } 

and when run "go run web.go" works fine on local computer. when try upload code openshift following error:

remote: -----> using go 1.1.2 remote: -----> running: go -tags openshift ./... remote: can't load package: /var/lib/openshift/5354e6fd4382ec2dca000223/app-root/runtime/repo/.openshift/g/src/github.com/smarterclayton/goexample/web.go:8:2: local import "./mylib" in non-local package remote: error occurred executing 'gear postreceive' (exit code: 1) remote: error message: client_error: failed execute: 'control build' /var/lib/openshift/5354e6fd4382ec2dca000223/go 

what mean? why can't golang find package? can't write code in 1 file. how should write application openshift?

i know question old had same problem , difficult find solution, decided ask in order run on same problem.

the solution simple , can found in readme of go cartdrige repo on github: github.com/smarterclayton/openshift-go-cart

you have create file named .godir , put here name of main package of server. example if put myserver can use:

package main import "myserver/mylib" func main() {     mylib.dostuff() } 

basically when push on openshift repo copied in directory placed in .godir before build


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

how to receive file in java(servlet/jsp) -