DEV Community

Discussion on: Embedding static files in Go

Collapse
 
ja7ad profile image
Javad Rajabzadeh • Edited

Thank you for this post , in

//go:embed sample.txt
var s string
fmt.Println(s)
Enter fullscreen mode Exit fullscreen mode

sample.txt auto embed to s string ?

For byte embed what do it?

Collapse
 
bhupesh profile image
Bhupesh Varshney 👾

Hi Javad, Sorry for the late reply. I just saw your comment
You just need to declare a byte variable to do this

    //go:embed sample.txt
    var b []byte
    fmt.Println(b)
Enter fullscreen mode Exit fullscreen mode