Skip to content

Native UUID type support #1866

Answered by satish71
sas1024 asked this question in Q&A
Mar 3, 2017 · 5 comments · 1 reply
Discussion options

You must be logged in to vote

I am new to go and go pg. Here is what I had learnt the hard way

  1. UUID is not build in support, you need add an UUID extension to a postgres database. this is a contrib. extension that's reason you need to explicitly create it.

CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

  1. Extension are per database. if you have create a new database. You need to repeat the above procedure
  2. Use the latest version of go-pg as earlier version had problem
  3. Ensure above imports, please pay attention the package references 'pg' and 'uuid'. We would using them.
import (
	pg "github.com/go-pg/pg/v10"
	"github.com/go-pg/pg/v10/orm"
	uuid "github.com/satori/go.uuid"
)
  1. You need now tell go-pg to correctly map you…

Replies: 5 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@vmihailenco
Comment options

Answer selected by vmihailenco
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #483 on April 06, 2021 06:53.