valid

command
Version: v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 9 Imported by: 0

README ยถ

valid

This program is a helper to check the output of utf8.Valid facilitate debugging. It accepts some input, runs both this library and stdlib's version of utf8.Valid, and prints out the result.

Usage

Provide the input as the the first argument to the program:

$ go run main.go "hello! ๐Ÿ˜Š"
hello! ๐Ÿ˜Š
[104 101 108 108 111 33 32 240 159 152 138]
11 bytes
stdlib: utf8: true ascii: false
valid:  utf8: true ascii: false v: 1

The input is parsed as a double quoted Go string, so you can use escape codes:

$ go run main.go "\xFA"

[250]
1 bytes
stdlib: utf8: false ascii: false
valid:  utf8: false ascii: false v: 0

Alternatively it can also conusme input from stdin:

$ cat example.txt
hello! ๐Ÿ˜Š
$ go run main.go < example.txt
hello! ๐Ÿ˜Š

[104 101 108 108 111 33 32 240 159 152 138 10]
12 bytes
stdlib: utf8: true ascii: false
valid:  utf8: true ascii: false v: 1

As a bonus, if the file is the result of a failure reported by Go 1.18 fuzz, the program extracts the actual value of the test:

$ cat fuzz.out
go test fuzz
[]byte("000000000000000000~\xFF")
$ go run main.go < fuzz.out
Got fuzzer input
000000000000000000~
[48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 126 255]
20 bytes
stdlib: utf8: false ascii: false
valid:  utf8: false ascii: false v: 0

GDB

A useful way to debug is to run this program with some problematic input and use GDB to step through the execution and inspect registers. The debug.gdb file is a basic helper to automate part of the process. For example:

$ go build main.go && gdb --command=debug.gdb  -ex "set args < ./example.txt" ./main

Documentation ยถ

The Go Gopher

There is no documentation for this package.

Source Files ยถ

Jump to

Keyboard shortcuts

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