Using GO Language, I am trying to send values from main to the function. I want to check if any parameter sent to function is empty. If there is any missing values, I want to print that the "Parameter value" is empty. If there are multiple parameters empty, I want to print that as well. If all parameters are correctly given, return the value.
func GetValue(a string, b string) (string, string) { emptyArray := []string{} intArray := [2]string{a, b} for i := 0; i < len(intArray); i++ { if intArray[i] == "" { values := append(emptyArray.intArray[]) fmt.Printf("Missing Values: %s ", values) break } else { fmt.Println("There is No missing value") } } return a, b } func main() { a,b := GetValue("", "playground") fmt.Println(a) fmt.Println(b) } **GetValue("hello","world") Expected Output: hello, world GetValue("","") Expected Output: A is missing, B is missing.** https://stackoverflow.com/questions/65623325/print-missing-values-using-go-language January 08, 2021 at 12:07PM
没有评论:
发表评论