Skip to content

Question: How to write a tag with a streamed content? #737

@ceving

Description

@ceving

I would like to encode CSV like data using the tag 275. I did the following:

	// Create encoder
	var enc *cbor.Encoder
	enc = cbor.NewEncoder(writer)

	// Encode a map-like serialized array
	err = enc.Encode(cbor.RawTag{Number: 275})
	if err != nil {
		return fmt.Errorf("Can not encode tag 275: %w", err);
	}
	
	// Encode begin of indefinite array
	err = enc.StartIndefiniteArray()
	if err != nil {
		return fmt.Errorf("Can not encode start of indefinite array: %w", err)
	}

This generates:

  • d9 01 13: Tag 275
  • f6: Null, because content of RawTag is nil
  • 9f: Start of indefinite array

How to get rid of the f6?

The struct RawTag seems to require always some content. This makes it impossible to stream the content.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions