Go Walk Tutorial-Process Control (switch)

Source: Internet
Author: User

Go switch is very flexible, the expression does not have to be a constant or an integer, the execution of the process from top to bottom until a match is found, do not break;

VAR score =98var result Stringswitch SCORE/10 {case 9,10:result= "excellent" Case 8:result= "good" case 6,7:result= "pass" default: Result= "Failed"}

The expression after switch is not even required

VAR score =-1var result Stringswitch  {case score<0:result= "negative" case score=0:result= "0" Case score>0:result= " Positive number "}

Lizi:

Package Mainimport ("Log") Import ("Github.com/lxn/walk"). "Github.com/lxn/walk/declarative") var le *walk. Lineeditvar sport,maths,english *walk. Radiobuttonfunc Main () {if _, err: = Mainwindow1.run (); Err! = nil {log. Fatal (Err)}log. Fatal (Bind ("enabledcb.checked"))}var mainwindow1=mainwindow{Title: "MainWindow", minsize:size{300, (+), layout:v  box{}, Children:widget,}var widget=[]widget{LineEdit1, Radiobuttonsport, Radiobuttonmaths, Radiobuttonenglish, Pushbuttonok,}var lineedit1=lineedit{assignto: &le,}var radiobuttonsport=radiobutton{AssignTo: &sport, Tex T: "Sports department",}var radiobuttonmaths=radiobutton{assignto: &maths, Text: "Mathematics department",}var Radiobuttonenglish=radiobutt on{Assignto: &english, Text: "English Department",}var pushbuttonok=pushbutton{Text: "OK", Onclicked:ok_clicked,}func OK_Cl icked () {switch {case 中文版. Checked (): le. SetText ("English Department") Case sport. Checked (): le. SetText ("sports department") case maths. Checked (): le. SetText ("Mathematics department ")}} 

  

RadioButton is a radio button that can be grouped,

Radiobuttongroup and Radiobuttongroupbox

Go Walk Tutorial-Process Control (switch)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.