一个HTTP分隔符来全部统治

I have a configuration file in the format of blah = foo. I would like to have entries like:

http = https://stackoverflow.com/questions,header keys and values,string to search for.

I'm okay requiring that the the url be urlecncoded. Is there any ASCII character I can use that won't be valid value anywhere in the above example (After splitting once on =)? My example uses a comma but I think that is valid in a header value?

After pouring through some RFCs I figure someone is more familiar with this can save me some pain.

Also my project is in Go if there are existing std library that might help with this...

You can use a non-ascii character and urlencode, for example using the middle dot (compose + ^ + . on linux):

const sep = `·`
const t = `http = https://stackoverflow.com/questions·string to search for·header=value·header=value`

func parseLine(line string) (name, url, search string, headers []string) {
    idx := strings.Index(line, " = ")
    if idx == -1 {
        return
    }
    name = line[:idx]
    parts := strings.Split(line[idx+3:], sep)
    if len(parts) < 3 {
        // handle invalid line
    }
    url, search = parts[0], parts[1]
    headers = parts[2:]
    return
}

Although, using JSON is probably the best and most long-term maintainable option.

For completeness sake, a json version would look like:

type Site struct {
    Url     string
    Query   string
    Headers map[string]string
}

const t = `[
    {
        "url": "https://stackoverflow.com/questions",
        "query": "string to search for",
        "headers": {"header": "value", "header2": "value"}
    },
    {
        "url": "https://google.com",
        "query": "string to search for",
        "headers": {"header": "value", "header2": "value"}
    }
]`

func main() {
    var sites []Site
    err := json.Unmarshal([]byte(t), &sites)
    fmt.Printf("%+v (%v)
", sites, err)
}

Essentially you have to look at RFC 3986, RFC 7230 and friends to see what can occur.

URIs are simple if you insist on them to be valid, just use the space character or "<" and ">" as delimiters.

Field values can be almost anything; HTTP forbids control characters though, so you might be able to use horizontal TABs (if you're ok with getting into trouble with invalid field values).