Go: cmd/go/internal/txtar: no escaping for file separator

Created on 13 May 2019  路  3Comments  路  Source: golang/go

The txtar file format is simple, but too simple. For example, an archive containing the file go/src/cmd/go/internal/txtar/archive_test.go itself will not round-trip correctly, because that file contains literals that look like file separators.

The spec should include an escaping/quoting scheme.

FrozenDueToAge NeedsInvestigation modules

Most helpful comment

Personally, I like the ultra-simple nature of the file format, although it's true that sometimes you do want to have a file that contains the separators. That's possible to work around, however. In this fork of testscript, I've provided unquote as a standard primitive. It just removes the leading > from the start of each line. I also changed the txtar-c command so that you can ask it to do the quoting for you.

Perhaps that approach might work for the internal testscript code too.

All 3 comments

Personally, I like the ultra-simple nature of the file format, although it's true that sometimes you do want to have a file that contains the separators. That's possible to work around, however. In this fork of testscript, I've provided unquote as a standard primitive. It just removes the leading > from the start of each line. I also changed the txtar-c command so that you can ask it to do the quoting for you.

Perhaps that approach might work for the internal testscript code too.

@jayconrod @bcmills

Agree with @rogpeppe, the simplicity of this format is really valuable. I'd rather not add features to it.

@ianthehat mentioned another case that doesn't roundtrip correctly: files that don't end with a newline. As with the unquote feature above, he recommends processing these files before and after packing them into txtar (adding newlines to files before packing, removing newlines after).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

go101 picture go101  路  3Comments

natefinch picture natefinch  路  3Comments

longzhizhi picture longzhizhi  路  3Comments

michaelsafyan picture michaelsafyan  路  3Comments

bradfitz picture bradfitz  路  3Comments