// 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
}