Home » 
        Code Examples » 
        Golang Code Examples
    
        
    Golang - Is there a way in go to convert a []byte slice to an io.Reader? Code Example
    
    
        
    Here is the solution for "Is there a way in go to convert a []byte slice to an io.Reader?" in Golang.
    Golang code for Is there a way in go to convert a []byte slice to an io.Reader?
package main
import (
    "bytes"
    "encoding/base64"
    "io"
    "os"
)
func main() {
    buf := bytes.NewBuffer([]byte("SGVsbG8sIFdvcmxkIQ=="))
    dec := base64.NewDecoder(base64.StdEncoding, buf)
    io.Copy(os.Stdout, dec)
}
/*
Output:
Hello, World!
*/
    
    
        Code by IncludeHelp,
        on March 4, 2023 23:34