goCloudK8sExampleServer

command
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: GPL-3.0 Imports: 20 Imported by: 0

README

goCloudK8sExampleServer

here is a simple golang server illustrating usage of this library

db migrations integration

we use go-migrate to give an example of embedding db-migrations sql scripts inside a server deployment.

You can check the postgres tutorial for go-migrate to gent more information.

inside this directory on your shell just use something like :

migrate create -ext sql -dir db/migrations -seq create_demo_type_table

will create those two files in the db/migrations directory:

000001_create_demo_table.down.sql
000001_create_demo_table.up.sql

then you can enter the corresponding up and down sql code.

whatever sql migrations are present on the db/migrations directory
will be used by the code near line 190

        // example of go-migrate db migration with embed files in go program
	// https://github.com/golang-migrate/migrate
	d, err := iofs.New(sqlMigrations, defaultSqlDbMigrationsPath)
	if err != nil {
		l.Fatalf("💥💥 error doing iofs.New for db migrations  error: %v\n", err)
	}
	m, err := migrate.NewWithSourceInstance("iofs", d, strings.Replace(dbDsn, "postgres", "pgx", 1))
	if err != nil {
		l.Fatalf("💥💥 error doing migrate.NewWithSourceInstance(iofs, dbURL:%s)  error: %v\n", dbDsn, err)
	}
	err = m.Up()
	if err != nil {
		l.Fatalf("💥💥 error doing migrate.Up error: %v\n", err)
	}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL