warn

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: MIT Imports: 6 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

Overview

Package warn holds what the readers share in saying what a fixed bound left out, and the messages of warnings several of them raise. The codes are go-fast-core's: this library has none of its own.

Index

Constants

View Source
const (
	MaxProjects       = 16
	MaxProjectSize    = 1 << 28
	MaxModules        = 1 << 12
	MaxPropertyName   = clean.MaxLabel
	MaxPropertyValue  = 64 << 10
	MaxCustomProps    = 256
	MaxProperties     = 1 << 12
	MaxObjects        = 1 << 12
	MaxObjectDepth    = 64
	MaxAddress        = clean.MaxAddress
	MaxName           = clean.MaxLabel
	MaxSheets         = 1 << 16
	MaxCols           = 1 << 14
	MaxComments       = 1 << 18
	MaxLinks          = 1 << 18
	MaxMerges         = 1 << 18
	MaxCellStyles     = 1 << 17
	MaxNumberFormats  = 1 << 13
	MaxFormula        = 32 << 10
	MaxNames          = 1 << 14
	MaxExternalLinks  = 1 << 16
	MaxExternalNames  = 1 << 16
	MaxSheetRefs      = 1 << 16
	MaxSharedFormulas = 1 << 20
	MaxChoiceLists    = 1 << 14
	MaxChoiceRanges   = 1 << 18
	MaxChartSeries    = 1 << 10
	MaxChartPoints    = 1 << 20
	MaxChartTitle     = 4096
	MaxChartTotal     = 1 << 21
	MaxCharts         = 1 << 12
	MaxSlides         = 1 << 16
	MaxSlideShapes    = 1 << 14
	MaxFieldCode      = 1 << 16
	MaxFieldDepth     = 64
	MaxTableCells     = 1 << 22
	MaxPivotTables    = 1 << 10
	MaxChartLookup    = 256 << 20
	MaxShapes         = 1 << 16
	MaxPictures       = 1 << 16
)

The bounds, where the code that keeps to them and the messages above both need them.

View Source
const (
	DamagedOne  = "stream could not be read to its end"
	DamagedMany = "streams could not be read to their end"
)

The nouns of the warning that parts could not be read to their end.

Variables

View Source
var ErrText = errors.New("the limit on the amount of text was reached")

ErrText is what a reader ends with when the document has taken all the text it may hold (gofastcore.Limits.MaxTextBytes).

Functions

func FitRows

func FitRows(budget *gofastcore.TextBudget, rows, cols int) int

FitRows returns how many of rows rows of cols cells a table block can have and stay within what budget has left, taking gofastcore.BlockCost for the block and gofastcore.CellCost for each cell (the cells' text was taken as it was read), and takes it. A result below rows means the table is cut there; 0 means not even its block fits, and nothing is taken.

func Over

func Over(s string) int64

Over returns how many bytes a name is longer than Name keeps; 0 if it is not.

func TextCut

func TextCut(noun string) string

TextCut is the message of the limit.exceeded warning on a part cut off for that reason; what stands for "part" is the kind of part.

func Unmapped

func Unmapped(n int) string

Unmapped is the message of gofastcore.WarnTextUnmappedGlyphs: n codes of a symbol font that have no character in Unicode.

func UnmappedEquation

func UnmappedEquation(n int) string

UnmappedEquation is the message of gofastcore.WarnTextUnmappedGlyphs for n characters of equations that Unicode has no character for.

Types

type Cap

type Cap uint8

Cap is a fixed bound of this library that can leave content out. Each is said once per part it left something out of, as limit.exceeded with severity error, with how much it left out; a bound that only bounds work loses nothing and is not here.

const (
	// Shared by the three formats.
	CapProjects Cap = iota
	CapProjectSize
	CapModules
	CapPropertyName
	CapPropertyValue
	CapCustomProps
	CapProperties
	CapObjects
	CapObjectDepth
	CapAddress
	CapName
	// Excel.
	CapSheets
	CapSheetCols
	CapComments
	CapLinks
	CapMerges
	CapCellStyles
	CapNumberFormats
	CapFormula
	CapNames
	CapExternalLinks
	CapExternalNames
	CapExternalSheets
	CapSheetRefs
	CapSharedFormulas
	CapChoiceLists
	CapChoiceRanges
	CapChartSeries
	CapChartPoints
	CapChartTitle
	CapChartTotal
	CapCharts
	CapShapes
	CapPictures
	CapChartLookup
	CapPivotTables
	// Word.
	CapFieldCode
	CapFieldDepth
	CapTableCells
	// PowerPoint.
	CapSlides
	CapSlideShapes
)

func (Cap) Message

func (c Cap) Message(n int64) string

Message is the text of the warning for n items a bound left out.

type Lost

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

Lost counts what the fixed bounds left out of one part, or of the document, bound by bound in the order met, so that the warnings come in an order that does not vary. The zero value is ready to use, and a nil *Lost counts nothing. Several goroutines may use it at once: what parts share (a chart, a master) may be read by any of them.

func (*Lost) Add

func (l *Lost) Add(c Cap, n int64)

Add records that the bound c left n more items out.

func (*Lost) AddCut

func (l *Lost) AddCut(c Cap, n, bytes int64)

AddCut records that the bound c cut n more texts short, leaving bytes bytes out.

func (*Lost) Address

func (l *Lost) Address(s string) string

Address is clean.Address, counting an address it cuts.

func (*Lost) Any

func (l *Lost) Any() bool

Any reports whether anything was counted.

func (*Lost) Count

func (l *Lost) Count(c Cap) int64

Count returns what the bound c left out.

func (*Lost) Label

func (l *Lost) Label(s string) string

Label is clean.Label, counting a label it cuts.

func (*Lost) Merge

func (l *Lost) Merge(o *Lost)

Merge adds what o counted to l, and leaves o as it is.

func (*Lost) Name

func (l *Lost) Name(s string) string

Name is clean.Name, counting a name it cuts.

func (*Lost) NameOver

func (l *Lost) NameOver(over int64)

NameOver counts a name over the bound by over bytes (Over), where it is put in the output.

func (*Lost) Say

func (l *Lost) Say(p *gofastcore.Part) bool

Say gives the warnings to p, one per bound, forgets what was counted, and reports whether there was any.

func (*Lost) Take

func (l *Lost) Take() *Lost

Take returns what was counted, and forgets it.

func (*Lost) Warnings

func (l *Lost) Warnings() []gofastcore.Warning

Warnings returns the warnings, one per bound, in the order met.

type Names

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

Names gathers what a warning that could repeat is about (parts that could not be read, references that lead nowhere), so that it is said once, with how many there are and the first few. The zero value is ready to use. Several goroutines may use it at once.

func (*Names) Add

func (l *Names) Add(name string)

Add counts one more, named name.

func (*Names) AddOnce

func (l *Names) AddOnce(name string)

AddOnce counts name if it has not been counted before.

func (*Names) Len

func (l *Names) Len() int64

Len returns how many were counted.

func (*Names) Message

func (l *Names) Message(one, many string) string

Message returns "N <noun> (a, b, ..., and K more)", with one or many as the noun, and forgets what was counted; "" if nothing was.

Jump to

Keyboard shortcuts

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