INNER CODE UNIT · Go

executor

c-bata/go-prompt · _example/http-prompt/main.go:102

func executor(in string) {
	in = strings.TrimSpace(in)

	var method, body string
	blocks := strings.Split(in, " ")
	switch blocks[0] {
	case "exit":
		fmt.Println("Bye!")
		os.Exit(0)
	case "cd":
		if len(blocks) < 2 {
			ctx.url.Path = "/"
		} else {
			ctx.url.Path = path.Join(ctx.url.Path, blocks[1])
		}
		return
	case "get", "delete":
		method = strings.ToUpper(blocks[0])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…