Help us shape the future of Go! Take the 2026 Go Developer Survey

announcement

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package announcement stores site-wide notices shown after sign-in.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Save

func Save(ctx context.Context, notices []Notice) error

Save writes the full list.

Types

type Notice

type Notice struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Body        string `json:"body"`
	Published   bool   `json:"published"`
	CreatedUnix int64  `json:"created_unix"`
}

Notice is one enterprise announcement.

func Delete

func Delete(notices []Notice, id string) []Notice

Delete removes one notice by id.

func Load

func Load(ctx context.Context) ([]Notice, error)

Load reads announcements. A missing record is an empty list.

func Published

func Published(notices []Notice) []Notice

Published returns notices that signed-in users should see, newest first.

func Upsert

func Upsert(notices []Notice, notice Notice, now time.Time) ([]Notice, error)

Upsert validates and inserts or replaces a notice.

type State

type State struct {
	Notices []Notice `json:"notices"`
}

State is the persisted announcement list.

func (*State) Name

func (s *State) Name() string

Name is the app-state key.

Jump to

Keyboard shortcuts

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