本文整理汇总了Golang中fmt.Println函数的典型用法代码示例。如果您正苦于以下问题:Golang Println函数的具体用法?Golang Println怎么用?Golang Println使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Println函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ExamplePayToAddrScript
// This example demonstrates creating a script which pays to a bitcoin address.
// It also prints the created script hex and uses the DisasmString function to
// display the disassembled script.
func ExamplePayToAddrScript() {
// Parse the address to send the coins to into a btcutil.Address
// which is useful to ensure the accuracy of the address and determine
// the address type. It is also required for the upcoming call to
// PayToAddrScript.
addressStr := "12gpXQVcCL2qhTNQgyLVdCFG2Qs2px98nV"
address, err := btcutil.DecodeAddress(addressStr, &btcnet.MainNetParams)
if err != nil {
fmt.Println(err)
return
}
// Create a public key script that pays to the address.
script, err := btcscript.PayToAddrScript(address)
if err != nil {
fmt.Println(err)
return
}
fmt.Printf("Script Hex: %x\n", script)
disasm, err := btcscript.DisasmString(script)
if err != nil {
fmt.Println(err)
return
}
fmt.Println("Script Disassembly:", disasm)
// Output:
// Script Hex: 76a914128004ff2fcaf13b2b91eb654b1dc2b674f7ec6188ac
// Script Disassembly: OP_DUP OP_HASH160 128004ff2fcaf13b2b91eb654b1dc2b674f7ec61 OP_EQUALVERIFY OP_CHECKSIG
}
开发者ID:stoiclabs,项目名称:blockchainr,代码行数:34,代码来源:example_test.go
示例2: TestSecureSecretoxKey
func TestSecureSecretoxKey(t *testing.T) {
key1, ok := secretbox.GenerateKey()
if !ok {
fmt.Println("pwkey: failed to generate test key")
t.FailNow()
}
skey, ok := SecureSecretboxKey(testPass, key1)
if !ok {
fmt.Println("pwkey: failed to secure secretbox key")
t.FailNow()
}
key, ok := RecoverSecretboxKey(testPass, skey)
if !ok {
fmt.Println("pwkey: failed to recover box private key")
t.FailNow()
}
if !bytes.Equal(key[:], key1[:]) {
fmt.Println("pwkey: recovered key doesn't match original")
t.FailNow()
}
if _, ok = RecoverBoxKey([]byte("Password"), skey); ok {
fmt.Println("pwkey: recover should fail with bad password")
t.FailNow()
}
}
开发者ID:postfix,项目名称:cryptobox-ng,代码行数:29,代码来源:pwkey_test.go
示例3: TestVersion
func TestVersion(t *testing.T) {
v := new(Version)
v.Version = uint16(1)
v.Timestamp = time.Unix(0, 0)
v.IpAddress = net.ParseIP("1.2.3.4")
v.Port = uint16(4444)
v.UserAgent = "Hello World!"
verBytes := v.GetBytes()
if len(verBytes) != verLen+12 {
fmt.Println("Incorrect Byte Length: ", verBytes)
t.Fail()
}
v2 := new(Version)
err := v2.FromBytes(verBytes)
if err != nil {
fmt.Println("Error Decoding: ", err)
t.FailNow()
}
if v2.Version != 1 || v2.Timestamp != time.Unix(0, 0) || v2.IpAddress.String() != "1.2.3.4" || v2.Port != 4444 || v2.UserAgent != "Hello World!" {
fmt.Println("Incorrect decoded version: ", v2)
t.Fail()
}
}
开发者ID:msecret,项目名称:emp,代码行数:26,代码来源:objects_test.go
示例4: getUberCost
func getUberCost(start locationStruct, end locationStruct) (int, int, float64, string) {
uberURL := strings.Replace(uberRequestURL, startLatitude, strconv.FormatFloat(start.Coordinate.Lat, 'f', -1, 64), -1)
uberURL = strings.Replace(uberURL, startLongitude, strconv.FormatFloat(start.Coordinate.Lng, 'f', -1, 64), -1)
uberURL = strings.Replace(uberURL, endLatitude, strconv.FormatFloat(end.Coordinate.Lat, 'f', -1, 64), -1)
uberURL = strings.Replace(uberURL, endLongitude, strconv.FormatFloat(end.Coordinate.Lng, 'f', -1, 64), -1)
res, err := http.Get(uberURL)
if err != nil {
//w.Write([]byte(`{ "error": "Unable to parse data from Google. Error at res, err := http.Get(url) -- line 75"}`))
fmt.Println("Unable to parse data from Google. Error at res, err := http.Get(url) -- line 75")
panic(err.Error())
}
body, err := ioutil.ReadAll(res.Body)
if err != nil {
//w.Write([]byte(`{ "error": "Unable to parse data from Google. body, err := ioutil.ReadAll(res.Body) -- line 84"}`))
fmt.Println("Unable to parse data from Google. Error at res, err := http.Get(url) -- line 84")
panic(err.Error())
}
var uberResult UberResults
_ = json.Unmarshal(body, &uberResult)
return uberResult.Prices[0].LowEstimate, uberResult.Prices[0].Duration, uberResult.Prices[0].Distance, uberResult.Prices[0].ProductID
}
开发者ID:savioferns321,项目名称:Uber_Trip_Requester,代码行数:29,代码来源:server.go
示例5: ExampleLambda_CreateFunction
func ExampleLambda_CreateFunction() {
svc := lambda.New(session.New())
params := &lambda.CreateFunctionInput{
Code: &lambda.FunctionCode{ // Required
S3Bucket: aws.String("S3Bucket"),
S3Key: aws.String("S3Key"),
S3ObjectVersion: aws.String("S3ObjectVersion"),
ZipFile: []byte("PAYLOAD"),
},
FunctionName: aws.String("FunctionName"), // Required
Handler: aws.String("Handler"), // Required
Role: aws.String("RoleArn"), // Required
Runtime: aws.String("Runtime"), // Required
Description: aws.String("Description"),
MemorySize: aws.Int64(1),
Publish: aws.Bool(true),
Timeout: aws.Int64(1),
}
resp, err := svc.CreateFunction(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:ernesto-jimenez,项目名称:goad,代码行数:31,代码来源:examples_test.go
最后编辑: kuteng 文档更新时间: 2021-08-23 19:14 作者:kuteng