main Package Penalty for Import ( "fmt" "the Math / RAND" "Time" ) / * * generate a random three-digit Jean users to enter their guess -feedback to the user: a big guess, guess small, you guessed it -if not I guessed continue guess If you guess right out of the game • If the user enters "-1" directly out of the game * / FUNC getRandom () {int / * get a random number * / // the n-: = rand.Intn (1000 ) // current elapsed time from the time at 0:00 on the 1970 nanoseconds sEED: = Time.now () UnixNano (). // ns using the current time as a random number seed myrandom: = rand.New (rand.NewSource (SEED)) n-: myrandom.Intn + = 100 (900) // returns the result of the random number to the caller return n- } FUNC main () { // call the random number acquired random number, the random number obtained answer: = getRandom ( ) the START: var int COUNT = 0 {for // let the user enter guess var GUESS int fmt.Println ( "Please enter your in Sao guess (100-999): - 1 = Exit, -2 = re-enter, 0 = replay") fmt.Scan (& GUESS) / * see if user wants to exit * / iF GUESS == -1 { BREAK } == 0 GUESS iF the else { // Continue GOTO the START } -2 == GUESS iF the else { // reenter // skip this the remaining portion of the cycle, the next cycle begins Continue } / * feedback to the user to guess a large, small guess, guessed * / COUNT ++ IF gUESS> {answer fmt.Printf ( "big guess, a common time% d \ n-", COUNT) } gUESS the else IF <answer { fmt.Printf (" guess small, a common time% d \ n-", COUNT) } the else { fmt.Printf (" guessed, a common time% d \ n ",COUNT) / * out of the loop * / BREAK } } fmt.Println("GAMEOVER!") }