app

package
v1.1.18 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Unlicense Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindTime

func BindTime(v time.Time) int64

func Must

func Must(c bool, format string, a ...any)

func MustBe

func MustBe(c bool)

func MustBeEqual

func MustBeEqual(a, b any)

func MustBeNil

func MustBeNil(a any)

func MustBeSet

func MustBeSet(a any)

func Run

func Run(makeDb func(dbfile string) Db)

func UnbindTime

func UnbindTime(v int64) time.Time

Types

type Article

type Article struct {
	Id      int
	Created time.Time
	UserId  int // the user that wrote this article
	Text    string
}

Articles are created by Users.

func NewArticle

func NewArticle(id int, created time.Time, userId int, text string) Article

type Comment

type Comment struct {
	Id        int
	Created   time.Time
	ArticleId int // the article that this comment is for
	Text      string
}

Comments are written for Articles.

func NewComment

func NewComment(id int, created time.Time, articleId int, text string) Comment

type Db

type Db interface {
	DriverName() string
	Exec(sqls ...string)
	InsertUsers(insertSql string, users []User)
	InsertArticles(insertSql string, articles []Article)
	InsertComments(insertSql string, comments []Comment)
	FindUsers(querySql string) []User
	FindUsersArticlesComments(querySql string) ([]User, []Article, []Comment)
	Close()
}

Db is the database interface.

type SqlDb

type SqlDb struct {
	// contains filtered or unexported fields
}

SqlDb is a Db implementation that uses database/sql package.

func NewSqlDb

func NewSqlDb(driverName string, db *sql.DB) *SqlDb

func (*SqlDb) Close

func (d *SqlDb) Close()

func (*SqlDb) DriverName

func (d *SqlDb) DriverName() string

func (*SqlDb) Exec

func (d *SqlDb) Exec(sqls ...string)

func (*SqlDb) FindArticles

func (d *SqlDb) FindArticles(querySql string) []Article

func (*SqlDb) FindUsers

func (d *SqlDb) FindUsers(querySql string) []User

func (*SqlDb) FindUsersArticlesComments

func (d *SqlDb) FindUsersArticlesComments(querySql string) ([]User, []Article, []Comment)

func (*SqlDb) InsertArticles

func (d *SqlDb) InsertArticles(insertSql string, articles []Article)

func (*SqlDb) InsertComments

func (d *SqlDb) InsertComments(insertSql string, comments []Comment)

func (*SqlDb) InsertUsers

func (d *SqlDb) InsertUsers(insertSql string, users []User)

type User

type User struct {
	Id      int
	Created time.Time
	Email   string
	Active  bool
}

User is a registered User who can access the blog.

func NewUser

func NewUser(id int, created time.Time, email string, active bool) User

Jump to

Keyboard shortcuts

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