Skip to content

Instantly share code, notes, and snippets.

View rodrwan's full-sized avatar
🇨🇱
cooking amazing code

Rod Fuenzalida rodrwan

🇨🇱
cooking amazing code
View GitHub Profile
package mediumexample
import (
"errors"
"time"
)
// User hold user information returned by UserService
type User struct {
ID string `json:"id,omitempty" db:"id"`
package mediumexample
import "time"
// Address hold address information returned by AddressStore
type Address struct {
UserID string `json:"user_id,omitempty" db:"user_id"`
AddressLine string `json:"address_line,omitempty" db:"address_line"`
City string `json:"city,omitempty" db:"city"`
Locality string `json:"locality,omitempty" db:"locality"`
// +build ignore
package main
import "github.com/99designs/gqlgen/cmd"
func main() {
cmd.Execute()
}
docker:
driver: postgres
dsn: postgres://mediumexample:me1234@localhost:5432/example?sslmode=disable
package database
import (
"os"
"github.com/jmoiron/sqlx"
mediumexample "github.com/rodrwan/medium-example"
"github.com/rodrwan/medium-example/database/postgres"
)
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
package postgres
import (
"database/sql"
"errors"
"time"
"github.com/Masterminds/squirrel"
"github.com/lib/pq"
mediumexample "github.com/rodrwan/medium-example"
package postgres
import (
"database/sql"
"errors"
"github.com/Masterminds/squirrel"
"github.com/lib/pq"
mediumexample "github.com/rodrwan/medium-example"
)
package graphql
import (
"context"
mediumexample "github.com/rodrwan/medium-example"
)
// Resolver represent a GraphQL resolver that need to implemente graphql interface.
type Resolver struct {
package service
import (
mediumexample "github.com/rodrwan/medium-example"
"github.com/rodrwan/medium-example/database"
)
// Users represents a User service that interact with database using Database.
type Users struct {
DBStore *database.Database