id

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package id list is responsible for id list managing

Index

Constants

This section is empty.

Variables

View Source
var (
	// List is the internal List instancem for 16 bit IDs enough
	List = make(ListT, 0, 65536)

	// FnJSON is the filename of the id list
	FnJSON string

	// DryRun if set, inhibits real changes
	DryRun bool
)

Functions

func Index

func Index(i int, l ListT) (int, error)

Index returns the index of 'ID' inside 'l'. If 'ID' is not inside 'l' Index() returns 0 and an error.

todo: replace it with functionality in InexEx

func IndexEx added in v0.9.2

func IndexEx(id int) (int, error)

IndexEx returns the index of id inside List. If is is not inside List Index returns 0 and an error.

func ListNotFoundMsg added in v0.9.2

func ListNotFoundMsg(pathname string)

ListNotFoundMsg give an output message about not found ID list.ListNotFoundMsg.

Base is used to avoid test issues in different operating systems.

func ScUpdate

func ScUpdate() error

ScUpdate is subcommand update

func ScZero

func ScZero(SrcZ string, cmd *flag.FlagSet) error

ScZero does replace all ID's in sourc tree with 0

Types

type Item

type Item struct {
	ID      int    `json:"id"`      // identifier
	FmtType string `json:"fmtType"` // format type (bitsize and number of fmt string parameters)
	FmtStrg string `json:"fmtStrg"` // format string
	Created int32  `json:"created"` // utc unix time of creation
	Removed int32  `json:"removed"` // utc unix time of disappearing in processed src directory
}

Item is the basic element

type ListT

type ListT []Item

ListT is a slice type containing the ID list

func (*ListT) FileWatcher

func (p *ListT) FileWatcher()

ListFileWatcher checks id list file for changes taken from https://medium.com/@skdomino/watch-this-file-watching-in-go-5b5a247cf71f

func (*ListT) Read

func (p *ListT) Read(fn string) error

Read is reading a JSON file fn and returning a slice

func (*ListT) Update

func (p *ListT) Update(root, fn string, run, verbose bool) error

Update is parsing source tree root and performing these actions: - replace FmtType( Id(0), ...) with FmtType( Id(n), ...) - find duplicate FmtType( Id(n), ...) and replace one of them if trices are not identical - extend file fnIDList

Jump to

Keyboard shortcuts

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