February 2018
Intermediate to advanced
340 pages
9h 43m
English
DROP TABLE IF EXISTS post; CREATE TABLE post ( ID serial, TITLE varchar(40), CONTENT varchar(255), CONSTRAINT pk_post PRIMARY KEY(ID) ); SELECT * FROM post;
package main import ( "database/sql" "fmt" _ "github.com/lib/pq" ) const trunc = "TRUNCATE TABLE post;" const ins = "INSERT INTO post(ID,TITLE,CONTENT) VALUES ($1,$2,$3)" var testTable = []struct { ID int Title string Content string }{ {1, "Title One", "Content of title one"}, {2, "Title Two", "Content of title two"}, {3, "Title Three", "Content of title three"}, } ...Read now
Unlock full access