You probably knew what switch was going to look like.

A case body breaks automatically, unless it ends with a fallthrough statement.

package main 

import (
"fmt"
"runtime"
) func main() {
fmt.Print("Go runs on ")
switch os := runtime.GOOS; os {
case "darwin":
fmt.Println("OS X.")
case "linux":
fmt.Println("Linux.")
default:
//freebsd,openbsd,
//plan9,windows...
fmt.Printf("%s.", os)
}
}

A Tour of Go Switch的更多相关文章

  1. A Tour of Go Switch with no condition

    Switch without a condition is the same as switch true. This construct can be a clean way to write lo ...

  2. A Tour of Go Switch evaluation order

    Switch cases evaluate cases from top to bottom, stopping when a case succeeds. (For example, switch ...

  3. go官网教程A Tour of Go

    http://tour.golang.org/#1 中文版:http://go-tour-cn.appsp0t.com/#4 package main import ( "fmt" ...

  4. A Swifr Tour

    Tradition suggests that the first program in a new language should print the words "Hello ,worl ...

  5. GO学习笔记 - 没有条件的 switch 同 switch true 一样。

    官方教程:https://tour.go-zh.org/flowcontrol/11 没有条件的 switch 同 switch true 一样. 这一构造使得可以用更清晰的形式来编写长的 if-th ...

  6. go tour - Go 入门实验教程

    在线实验地址 - 官网 在线实验地址 - 国内 可以将官方教程作为独立程序在本地安装使用,这样无需访问互联网就能运行,且速度更快,因为是在你的机器上构建并运行代码示例. 本地运行此教程的中文版的步骤如 ...

  7. Partition:分区切换(Switch)

    在SQL Server中,对超级大表做数据归档,使用select和delete命令是十分耗费CPU时间和Disk空间的,SQL Server必须记录相应数量的事务日志,而使用switch操作归档分区表 ...

  8. java中if和switch哪个效率快

    首先要看一个问题,if 语句适用范围比较广,只要是 boolean 表达式都可以用 if 判断:而 switch 只能对基本类型进行数值比较.两者的可比性就仅限在两个基本类型比较的范围内.说到基本类型 ...

  9. [开源]QuickSwitchSVNClient,快速完成SVN Switch的工具

    在实际的开发中,我们一般使用SVN工具进行源代码的管理.在实际的产品开发中,根据项目的一些定制要求,往往需要对某一些代码的修改,但是又不想影响主要的开发,这个时候需要对当前的主分支做一些分支处理(br ...

随机推荐

  1. CentOS7.1配置远程桌面

    网上看了很多资料,完全是乱的. 我使用的是CentOS7.1的系统.我的要求是windows的客户机可以远程访问CentOS系统. 1,首先需要检查一下服务器是否已经安装了VNC服务,检查服务器的是否 ...

  2. Ubuntu 学习笔记

    1.   ubuntu开启root账号,设置分配很简单,只要为root设置一个root密码就行了: $ sudo passwd root 之后会提示要输入root用户的密码,连续输入root密码,再使 ...

  3. C#获取cpu序列号 硬盘ID 网卡硬地址以及操作注册表 .

    转:http://blog.csdn.net/smartsmile2012/article/details/8682295 #region 获取cpu序列号 硬盘ID 网卡硬地址 /**/ /// & ...

  4. 24点C++程序实现 编程之美1.16

    解法1,对于任意输入的四个数字,给出一个24点的解法,若无解,则没有输出. 原理参照下图(编程之美原书) 代码如下,仅供参考 // 1.16.cpp : Defines the entry point ...

  5. python学习笔记五--文件

    任何情况下文本文件在Python里均是字符串模式. 一.创建一个文件,并写入: 函数open(文件名,w) 二.打开一个文件,并读取: 函数open(文件名,r),“r”是默认值,可以不用写 三.使用 ...

  6. STM32硬件复位时间

    两个参数,,1低电平时间 2低电平压值 1.stm32复位时间 ------  低电平时间:1.5 至 4.5 ms   2.压值

  7. Android之AndroidManifest.xml文件解析

    转自:Android学习笔记之AndroidManifest.xml文件解析 一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文 ...

  8. WINCE6.0+ILI9806E休眠唤醒显示异常问题

    我们的系统WINCE6.0,它支持睡眠和唤醒,目的是想在不使用的时候让设备进入睡眠状态,降低功耗,我们遇到的问题就是设备正常启动后正常显示,但睡眠然后唤醒后要么显示白屏要么是条纹状白屏,如下图: 图1 ...

  9. uva 489 Hangman Judge(水题)

    题目:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&am ...

  10. php 类 成员变量 $this->name='abc'

    <?php class test { public function getName() { $this->name='abc'; echo $this->name; } }$a=n ...