File: testargs.go

package info (click to toggle)
delve 1.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 15,136 kB
  • sloc: ansic: 111,947; sh: 194; asm: 147; makefile: 43; python: 23
file content (20 lines) | stat: -rw-r--r-- 471 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package main

import (
	"fmt"
	"os"
)

func main() {
	// this test expects AT LEAST 1 argument, and the first one needs to be "test".
	// second one is optional but if given, it should be "-passFlag"
	fmt.Printf("received args %#v\n", os.Args)
	if len(os.Args) < 2 {
		panic("os.args too short!")
	} else if os.Args[1] != "test" {
		panic("os.args[1] is not test!")
	}
	if len(os.Args) >= 3 && os.Args[2] != "pass flag" {
		panic("os.args[2] is not \"pass flag\"!")
	}
}