Skip to content

Instantly share code, notes, and snippets.

package main
import (
"net/http"
"sample-app/handler"
"sample-app/provider"
"sample-app/provider/sql"
"sample-app/service"
)
package handler
import (
"net/http"
"github.com/go-chi/chi"
"sample-app/handler/api"
"sample-app/service"
)
package api
import (
"net/http"
"strconv"
"sample-app/service"
"sample-app/util"
)
package service
type BaseFactory interface {
NewBase() Base
}
type baseFactory struct {
StorageFactory
}
package service
import (
"encoding/json"
)
type Base interface {
GetData() json.RawMessage
}
package sql
import (
"github.com/jinzhu/gorm"
"sample-app/service"
)
type storageFactory struct {
Db *gorm.DB
package sql
import (
"encoding/json"
"fmt"
"reflect"
"github.com/jinzhu/gorm"
"sample-app/model"
package service
import "encoding/json"
type BaseRepository interface {
GetRows(models []string) json.RawMessage
}
type StorageFactory interface {
NewBaseRepository() BaseRepository
package provider
import (
"github.com/jinzhu/gorm"
_ "github.com/lib/pq"
"sample-app/model"
"sample-app/util"
)
package model
import (
"encoding/json"
"time"
)
type Building struct {
ID uint `gorm:"primary_key" json:"id"`
CreatedAt time.Time `json:"-"`