RUN go get ./...
все ложится:package application/database: unrecognized import path "application/database" (import path does not begin with hostname)
package application/routes: unrecognized import path "application/routes" (import path does not begin with hostname)
package application/utils: unrecognized import path "application/utils" (import path does not begin with hostname)
package application/models: unrecognized import path "application/models" (import path does not begin with hostname)
package gopkg.in/goracle.v2: unrecognized import path "gopkg.in/goracle.v2" (https fetch: Get https://gopkg.in/goracle.v2?go-get=1: proxyconnect tcp: tls: oversized record received with length 20527)
package application/controllers: unrecognized import path "application/controllers" (import path does not begin with hostname)
- application
- database
- routes
- utils
- models
- controllers
main.go
Dockerfile
FROM golang:1.11
RUN go get github.com/gorilla/mux && \
go get github.com/gorilla/handlers && \
go get github.com/lib/pq && \
go get github.com/joho/godotenv && \
go get github.com/jinzhu/gorm && \
go get gopkg.in/goracle.v2
ADD ./ /go/src/application
WORKDIR /go/src/application
RUN go build -o /service application
ENV PORT=8000
CMD ["/service "]
package gopkg.in/goracle.v2: unrecognized import path "gopkg.in/goracle.v2" (https fetch: Get https://gopkg.in/goracle.v2?go-get=1: proxyconnect tcp: tls: first record does not look like a TLS handshake)
The command '/bin/sh -c go get github.com/gorilla/mux && go get github.com/gorilla/handlers && go get github.com/lib/pq && go get github.com/joho/godotenv && go get github.com/jinzhu/gorm && go get gopkg.in/goracle.v2' returned a non-zero code: 1
gopkg.in/goracle.v2
. Есть ли идеи на счет этого? GCC
cо значением C:\TDM-GCC-64
set GOOS=linux
set GOARCH=amd64
go build -v -o questionnaire -ldflags="-extld=$GCC"
RUN chmod +x /service
, как вы советовали. Контейнер создался, но не запустился. Выдает теперь такую ошибку:standard_init_linux.go:178: exec user process caused "exec format error"
linux/amd64
. Могу ошибаться, возможно вместо FROM alpine
нужно указать что-то другое. Что думаете на счет этого? - application
- database
- routes
- utils
- models
- controllers
main.go
Dockerfile
RUN go build -o /bin application
вызывает ошибку следующего рода:main.go:9:2: cannot find package "application/database" in any of:
/usr/local/go/src/application/database (from $GOROOT)
/go/src/application/database (from $GOPATH)
main.go:10:2: cannot find package "application/routes" in any of:
/usr/local/go/src/application/routes (from $GOROOT)
/go/src/application/routes (from $GOPATH)
main.go:11:2: cannot find package "questionnaire/utils" in any of:
/usr/local/go/src/application/utils (from $GOROOT)
/go/src/application/utils (from $GOPATH)
package main
import (
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/joho/godotenv"
"log"
"net/http"
"application/database"
"application/routes"
"application/utils"
)
func main() {
err := godotenv.Load(".env")
if err != nil {
panic(err)
}
database.ConnectOracle()
defer database.DisconnectOracle()
router := mux.NewRouter()
headers := handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"})
methods := handlers.AllowedMethods([]string{"GET", "POST", "PATCH", "PUT", "DELETE", "OPTIONS"})
origins := handlers.AllowedOrigins([]string{"*"})
router.StrictSlash(true)
routes.Handle(router)
port := utils.CheckEnvironmentVariable("APPLICATION_PORT")
log.Printf("RESTful web service is running on %s port.", port)
log.Fatal(http.ListenAndServe(":" + port, handlers.CORS(headers, methods, origins)(router)))
}
FROM ubuntu:16.04
RUN apt-get update -y -q && apt-get upgrade -y -q
RUN DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -q curl build-essential ca-certificates git
RUN curl -s https://storage.googleapis.com/golang/go1.11.linux-amd64.tar.gz| tar -v -C /usr/local -xz
ENV GOPATH /go
ENV GOROOT /usr/local/go
ENV PATH $PATH:/usr/local/go/bin
RUN go get github.com/gorilla/mux
RUN go get github.com/gorilla/handlers
RUN go get github.com/lib/pq
RUN go get github.com/joho/godotenv
RUN go get -u github.com/jinzhu/gorm
RUN go get gopkg.in/goracle.v2
ADD ./src /go/src/application
WORKDIR /go/src/application
RUN go build -o /bin application
ENV PORT=8000
CMD ["/go/src/bin"]
docker pull karalabe/xgo-latest
xgo .
xgo: command not found
xgo -targets linux/amd64 .
2019/03/11 17:29:33 Failed to check docker installation: exec: "docker": executable file not found in %PATH%.
Error parsing reference: "golang:1.12 as builder" is not a valid repository/tag: invalid reference format
FROM golang:1.11.2-stretch
ADD ./src /go/src/application
WORKDIR /go/src/application
RUN go get gopkg.in/goracle.v2
ENV PORT=8000
CMD ["go", "run", "main.go"]
go get
. К слову как в Dockerfile указать на скачивания сторонних библиотек?type Organisation struct {
ID int `json:"organization_id"`
Name string `json:"ogranization_name"`
Children []Organisation `json:"childs"`
}
rows,err := db.Query("select * from ORG_TABLE")
if err != nil {
fmt.Println(err)
return
}
for rows.Next() {
var organization Organization
err = rows.Scan(&organization.ID, &organization.Name, ???)
if err != nil {
fmt.Println(err)
return
}
}
type Survey struct {
SurveyID string `gorm:"primary_key" json:"survey_id"`
SurveyName string `gorm:"not null" json:"survey_name"`
Questions []Question
}
type Question struct {
QuestionID int `gorm:"primary_key" json:"question_id"`
QuestionText string `gorm:"not null;unique" json:"question_text"`
Options []Option
}
type Option struct {
OptionID int `gorm:"primary_key" json:"option_id"`
OptionText string `gorm:"not null;unique" json:"option_text"`
}
ret.Description = &in.Description.Value
&in.Description.Value
.Cannot use '&in.Description.Value' (type *func() (driver.Value, error)) as type utils.NullString in assignment less...
Inspection info: Reports incompatible types in binary and unary expressions.