我是 go lang 开发的初学者,我尝试从 go 服务器连接云 oracle 数据库(使用 'github.com/godror/godror' 包)。我安装了 Oracle 即时客户端并设置了环境路径。


Go 服务器正在运行并且能够建立连接和查询。但是当我构建一个生产应用程序时出现了这些错误。


命令:env GOOS=linux GOARCH=amd64 go build -o odb db_main.go


../github.com/godror/godror/orahlp.go:452:53: undefined: VersionInfo

../github.com/godror/godror/orahlp.go:461:53: undefined: VersionInfo

../github.com/godror/godror/orahlp.go:479:19: undefined: VersionInfo

../github.com/godror/godror/orahlp.go:480:19: undefined: VersionInfo

../github.com/godror/godror/orahlp.go:481:30: undefined: ObjectType

../github.com/godror/godror/orahlp.go:482:31: undefined: Event

../github.com/godror/godror/orahlp.go:482:42: undefined: SubscriptionOption

../github.com/godror/godror/orahlp.go:482:64: undefined: Subscription

../github.com/godror/godror/orahlp.go:483:10: undefined: StartupMode

../github.com/godror/godror/orahlp.go:484:11: undefined: ShutdownMode

../github.com/godror/godror/orahlp.go:484:11: too many errors```




My server code(db_main.go)

```package main

import (

    "database/sql"

    "encoding/json"

    "fmt"

    "log"

    "net/http"

    "time"



_ "github.com/godror/godror"

)



//  VersionInfo,ObjectType,Event,SubscriptionOption,Subscription,StartupMode,ShutdownMode

var db *sql.DB


func main() {

    var err error


    db, err = sql.Open("godror", "xyz/abc@13.43.11.8:1521/sampledb")

    if err != nil {

        log.Println("Error")

        fmt.Println(err)

        return

    }

    defer db.Close()


    port := ":8000"

    http.HandleFunc("/insert", InsertData)

    http.HandleFunc("/list", GetList)

    log.Println("Tranzo-Shahi Oracle DB running in ", port)

    httpErr := http.ListenAndServe(port, nil)

    if httpErr != nil {

        log.Println("Tranzo-Shahi Oracle DB Error: ", httpErr.Error())

    }

}