add

AI-Driven Development
git clone git://git.lair.cx/add
Log | Files | Refs | README

helloworld_test.go (541B)


      1 package main
      2 
      3 import (
      4 	"fmt"
      5 	"log"
      6 	"os"
      7 )
      8 
      9 func main() {
     10 	if len(os.Args) < 2 {
     11 		log.Fatalf("Usage: %s (name)", os.Args[0])
     12 	}
     13 
     14 	fmt.Println(MakeGreeting(os.Args[1], true))
     15 	fmt.Println(MakeGreeting(os.Args[1], false))
     16 }
     17 
     18 // Below is generated code
     19 
     20 // MakeGreeting generates a personalized greeting message based on the given name and whether the person has entered the room.
     21 func MakeGreeting(name string, entered bool) string {
     22 	if entered {
     23 		return fmt.Sprintf("Hi, %s!", name)
     24 	} else {
     25 		return fmt.Sprintf("Bye, %s!", name)
     26 	}
     27 }