Skip to content

Panic #400

@kaibox-git

Description

@kaibox-git

I cut structures for readability. It works with "encoding/json", but panics with "github.com/goccy/go-json"

package main

import (
	"github.com/goccy/go-json"
)

// "encoding/json"
// "github.com/goccy/go-json"

type Auth struct {
	Id                  int                  `json:"id"`
	Login               string               `json:"login"`
	CurrentOrganization *CurrentOrganization `json:"organization,omitempty" db:"organization"`
}

type CurrentOrganization struct {
	Id int `json:"id"`
}

type User struct {
	Auth
}

type AddUser struct {
	User
}

func main() {
	user := new(AddUser)
	user.Login = "user756"

	jsonUser, err := json.Marshal(user)
	if err != nil {
		println("error:", err.Error())
	}
	println("user:", jsonUser)
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions