dotemacs

My Emacs configuration
git clone git://git.entf.net/dotemacs
Log | Files | Refs | LICENSE

switch.go (825B)


      1 package _switch
      2 
      3 func main() {
      4 	switch "" {
      5 	case "foo":
      6 	label:
      7 		code()
      8 	case "bar":
      9 	case "baz": // important comma,
     10 		if true {
     11 			return
     12 		}
     13 	case "meow": // some documentation
     14 	default:
     15 		code()
     16 	}
     17 
     18 	switch 123 {
     19 	case 1, 2,
     20 		3:
     21 	case
     22 		1,
     23 		3:
     24 	case
     25 		// hi
     26 		"hi",
     27 		"there":
     28 		code()
     29 	case
     30 		/* hi
     31 		   there */
     32 		"hi",    // hi
     33 		"there": // there
     34 	}
     35 
     36 	switch {
     37 	// attached
     38 	case true:
     39 		// body
     40 		code()
     41 		// could go either way
     42 	case true:
     43 	// could go either way
     44 	case true:
     45 		// could go both ways
     46 	// could go both ways
     47 	case true:
     48 
     49 	/* this works too */
     50 	case true:
     51 
     52 	/* hi */
     53 	/* this works too */
     54 	case true:
     55 
     56 	/* hi
     57 	   this works too */
     58 	case true:
     59 
     60 	// could go either way
     61 	case true:
     62 
     63 		// could go either way
     64 	case true:
     65 
     66 	// also works
     67 	default:
     68 	}
     69 
     70 	switch {
     71 	case 1:
     72 	case foo,
     73 		foo,
     74 		foo:
     75 	}
     76 }