first ecli commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
|
||||
// All rights reserved.
|
||||
|
||||
// util-string.go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func checkStringLiteral(literal string) (value string, err error) {
|
||||
length := len(literal)
|
||||
if length >= 2 {
|
||||
if (literal[0] == '"' && literal[length-1] == '"') || literal[0] == '\'' && literal[length-1] == '\'' {
|
||||
value = literal[1 : length-1]
|
||||
} else {
|
||||
err = fmt.Errorf("unquoted or partially quoted string literal: `%s`", literal)
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("invalid string literal: `%s`", literal)
|
||||
}
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user