Last active
September 25, 2018 07:18
-
-
Save hysios/6cda1d10412941a0c475bfe2a1744f47 to your computer and use it in GitHub Desktop.
sqlite3 compile at linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:1.11.0 as builder | |
RUN apt-get -y update && apt-get install -y sqlite3 libsqlite3-dev | |
COPY . /go/src/sqltest | |
WORKDIR /go/src/sqltest | |
RUN go build -o sqltest main.go | |
FROM golang:1.11.0 | |
COPY --from=builder /go/src/sqltest/sqltest . | |
CMD ["./sqltest"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
_ "github.com/mattn/go-sqlite3" | |
"github.com/jinzhu/gorm" | |
) | |
type User struct { | |
gorm.Model | |
UserName string | |
} | |
func main() { | |
log.Printf("sqlite") | |
db, err := gorm.Open("sqlite3", "test.db") | |
if err != nil { | |
log.Fatalln("open database error") | |
} | |
defer db.Close() | |
log.Printf("database %#v", db) | |
db.AutoMigrate(&User{}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
build: | |
@docker build --rm -t sqltest . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment