嵌套开关在golang中合法吗? [关闭]

I hope golang syntax can be time resistant (meaning if I write my code now, 10 years time the syntax is still valid)

            switch strings.ToLower(firstCommand) {
            default:
                    fmt.Println("Default 1st Nest")

            case "c":
                    fmt.Println("C CREATE")
                    fallthrough
            case "u":
                    fmt.Println("U UPDATE")
                    fallthrough
            case "d":
                    fmt.Println("D DELETE")
                    dosomething()

                    switch strings.ToLower(secondCommand) {
                    default:
                    fmt.Println("Default 2nd Nest")

                    case "a":
                    donothing()

                    }
           }

is the above code syntax legit? I mean, will it stand the test of time? Otherwise, what is a better way to write this?

Read the The Go Programming Language Specification, the Go 1 compatibility guarantees, and the planning for Go 2.


The Go Programming Language Specification

Blocks

Each clause in a "switch" or "select" statement acts as an implicit block.

Switch statements

"Switch" statements provide multi-way execution. An expression or type specifier is compared to the "cases" inside the "switch" to determine which branch to execute.


Go 1 and the Future of Go Programs

It is intended that programs written to the Go 1 specification will continue to compile and run correctly, unchanged, over the lifetime of that specification. At some indefinite point, a Go 2 specification may arise, but until that time, Go programs that work today should continue to work even as future "point" releases of Go 1 arise (Go 1.1, Go 1.2, etc.).


The Go Blog: Toward Go 2

This is the text of my [Russ Cox] talk today at Gophercon 2017, asking for the entire Go community's help as we discuss and plan Go 2.

Finally, how will we ship and deliver Go 2?

I think the best plan would be to ship the backwards-compatible parts of Go 2 incrementally, feature by feature, as part of the Go 1 release sequence.

Once all the backwards-compatible work is done, say in Go 1.20, then we can make the backwards-incompatible changes in Go 2.0.

This is all a bit speculative, and the specific release numbers I just mentioned are placeholders for ballpark estimates, but I want to make clear that we're not abandoning Go 1, and that in fact we will bring Go 1 along to the greatest extent possible.


Compile and test a proof-of-concept program. For example,

package main

import (
    "fmt"
    "strings"
)

func dosomething() {}

func donothing() {}

func main() {
    var firstCommand, secondCommand string
    switch strings.ToLower(firstCommand) {
    default:
        fmt.Println("Default 1st Nest")
    case "c":
        fmt.Println("C CREATE")
        fallthrough
    case "u":
        fmt.Println("U UPDATE")
        fallthrough
    case "d":
        fmt.Println("D DELETE")
        dosomething()

        switch strings.ToLower(secondCommand) {
        default:
            fmt.Println("Default 2nd Nest")
        case "a":
            donothing()
        }
    }
}

Playground: https://play.golang.org/p/Q1ZdYqeNk67

Output:

Default 1st Nest

Now, you have an authoritative answer.