Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Go 如何向扫描语句添加提示?_Go_Input_Scanf_Prompt - Fatal编程技术网

Go 如何向扫描语句添加提示?

Go 如何向扫描语句添加提示?,go,input,scanf,prompt,Go,Input,Scanf,Prompt,问题:如何在GoLang中向扫描语句的开头添加提示 电流输出: 期望输出: 我的代码: 顺便说一句,我很抱歉发布这样一个基本的问题。 我花了几个小时研究,但我真的找不到答案。我找到了答案。 如果其他人有此问题,这里有一个解决方案: 使用fmt。在扫描语句之前打印 例子: 我想出来了。 如果其他人有此问题,这里有一个解决方案: 使用fmt。在扫描语句之前打印 例子: Enter Phrase: Hello World! You typed: Hello world! Enter Phrase:

问题:如何在GoLang中向扫描语句的开头添加提示

电流输出: 期望输出: 我的代码: 顺便说一句,我很抱歉发布这样一个基本的问题。 我花了几个小时研究,但我真的找不到答案。

我找到了答案。
如果其他人有此问题,这里有一个解决方案:
使用fmt。在扫描语句之前打印

例子: 我想出来了。
如果其他人有此问题,这里有一个解决方案:
使用fmt。在扫描语句之前打印

例子:
Enter Phrase:
Hello World!
You typed: Hello world!
Enter Phrase: Hello world!
You typed: Hello world!
package main

import(
    "fmt"
)

func main() {
    var phrase string
    fmt.Println("Enter Phrase: ")
    fmt.Scan(&phrase)
    fmt.Println("You typed: ", phrase)
}
package main

import(
    "fmt"
)

func main() {
    var phrase string
    fmt.Print("Enter Phrase: ")
    fmt.Scanln(&phrase)
    fmt.Println("You typed: ", phrase)
}