Lindenii Project Forge
Login

go-lindenii-common

Common library for the Lindenii Project
Commit info
ID
35d69905e2fc47c9b13e5d7e4ffbd0b6b277a76e
Author
Runxi Yu <me@runxiyu.org>
Author date
Sun, 12 Jan 2025 04:22:49 +0800
Committer
Runxi Yu <me@runxiyu.org>
Committer date
Sun, 12 Jan 2025 04:22:49 +0800
Actions
mailkit: Strip_angle_brackets
package mailkit

// Strip_angle_brackets strips a single "<" from the
// front of the string and a single ">" from the back
// of the string. If either are present, stripped
// returns true; if both are present, balanced also
// returns true.
func Strip_angle_brackets(x string) (result string, stripped bool, balanced bool) {
	var tmp string
	if x[0] == '<' {
		tmp = x[1:]
		stripped = true
	} else {
		tmp = x
	}
	if tmp[len(tmp)-1] == '>' {
		result = tmp[:len(tmp)-1]
		if stripped {
			balanced = true
		} else {
			stripped = true
		}
	} else {
		result = tmp
	}
	return
}