Documentation ¶
Index ¶
- Constants
- func ContextWithContent(ctx context.Context, fs fs.FS, name string) context.Context
- func ParseBuffer(buf []byte) (map[string]string, error)
- func ParseLine(line string) (string, string, error)
- func ProcessContent[T any](ctx context.Context) (T, error)
- func ProcessEntry[T any](fs *Entry) (T, error)
- func ReadDir(fsys fs.FS, name string) ([]fs.DirEntry, error)
- func ReadFile(fsys fs.FS, name string) ([]byte, error)
- func ReadMap(fsys fs.FS, name string) (map[string]string, error)
- type Entry
Examples ¶
Constants ¶
View Source
const ( // Scheme - file system entry Scheme = "fse" ErrorText = "error.txt" ErrText = "err.txt" )
Variables ¶
This section is empty.
Functions ¶
func ContextWithContent ¶
ContextWithContent - creates a new Context with content
func ProcessContent ¶
ProcessContent - process content
Example ¶
ctx := ContextWithContent(nil, fsys, "resource/error/test-name-eRr.txt") _, err := ProcessContent[CustomerHistory](ctx) fmt.Printf("Error : %v\n", err) ctx = ContextWithContent(nil, fsys, "resource/json/event.json") cust, err0 := ProcessContent[CustomerHistory](ctx) fmt.Printf("Error : %v\n", err0) fmt.Printf("Cust : %v\n", cust) ctx = ContextWithContent(nil, fsys, "resource/json/event-list.json") list, err1 := ProcessContent[[]CustomerHistory](ctx) fmt.Printf("Error : %v\n", err1) fmt.Printf("List : %v\n", list)
Output: Error : This is example 1 of an error from test-name-eRr.txt Error : <nil> Cust : {C1 [{ invoice created 2022-08-25 0001} { payment created 2022-08-26 0002}]} Error : <nil> List : [{C1 [{ invoice created 2022-08-25 0001} { payment created 2022-08-26 0002}]} {C0002 [{ return created 2022-10-25 99990001} { credit created 2022-11-01 0002333}]}]
func ProcessEntry ¶
ProcessEntry - process content that is fs entry
Types ¶
Click to show internal directories.
Click to hide internal directories.