INNER CODE UNIT · Go

ReaderToBytes

krisnova/naml · codify.go:225

func ReaderToBytes(input io.Reader) ([]byte, error) {
	var code []byte
	ibytes, err := io.ReadAll(input)
	if err != nil {
		return code, fmt.Errorf("unable to read all of stdin: %v", err)
	}
	logger.Debug("Read %d bytes from stdin", len(ibytes))
	return ibytes, nil
}

// ReaderToCodifyObjects will convert an io.Reader to naml compatible Go objects.
//
// This function works by doing the best it can, and will return as many CodifyObjects
// as possible.
// The function will return a positive integer for every YAML object it detects, that
// it is unable to Codify.
// If the delta is greater than 0, that means we have encountered a loss.
func ReaderToCodifyObjects(input io.Reader) ([]CodifyObject, int, error) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…