The encoding package in Go does not exist; you likely need encoding/json, encoding/xml, or encoding/gob for data serialization, or encoding/base64 for binary encoding. Import the specific subpackage you need and use its functions directly, such as json.Marshal to convert a struct to JSON bytes.
package main
import (
"encoding/json"
"fmt"
)
type Person struct {
Name string `json:"name"`
Age int `json:"age"`
}
func main() {
p := Person{Name: "Alice", Age: 30}
data, err := json.Marshal(p)
if err != nil {
panic(err)
}
fmt.Println(string(data))
}