"K8s.io/utils/ptr"의 두 판 사이의 차이

 
13번째 줄: 13번째 줄:


func main() {
func main() {
var p *string
var s string = "Hello, world!"
p = ptr.To[string]("Hello, world!")
var p *string = ptr.To[string](s)
fmt.Println(*p)     // Hello, world!
fmt.Println(*p) // Hello, world!
fmt.Printf("%#v", p) // (*string)(0xc000096020)Hello, world!
fmt.Println(p) // 0xc00008e040
}
}
</syntaxhighlight>
</syntaxhighlight>

2024년 5월 10일 (금) 15:05 기준 최신판

1 개요[ | ]

k8s.io/utils/ptr
package main

import (
	"fmt"

	"k8s.io/utils/ptr"
)

func main() {
	var s string = "Hello, world!"
	var p *string = ptr.To[string](s)
	fmt.Println(*p) // Hello, world!
	fmt.Println(p)  // 0xc00008e040
}

2 같이 보기[ | ]

3 참고[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}