Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👾 ChatID for optional fields #23

Closed
mymmrac opened this issue Apr 1, 2022 · 1 comment
Closed

👾 ChatID for optional fields #23

mymmrac opened this issue Apr 1, 2022 · 1 comment
Assignees
Labels
👾 Bug Something isn't working

Comments

@mymmrac
Copy link
Owner

mymmrac commented Apr 1, 2022

💬 Telego version

v0.10.3

👾 Issue description

ChatID can't be empty even if it's optional

⚡️ Expected behavior

ChatID to be able to use in optional fields

🧐 Code example

// MarshalJSON returns JSON representation of ChatID
func (c ChatID) MarshalJSON() ([]byte, error) {
	if c.ID != 0 {
		return json.Marshal(c.ID)
	}

	if c.Username != "" {
		return json.Marshal(c.Username)
	}

	return nil, errors.New("chat ID and username are empty")
}
@mymmrac mymmrac added the 👾 Bug Something isn't working label Apr 1, 2022
@mymmrac mymmrac self-assigned this Apr 1, 2022
mymmrac added a commit that referenced this issue Apr 26, 2022
@mymmrac
Copy link
Owner Author

mymmrac commented Apr 26, 2022

Resolved in v0.10.4

@mymmrac mymmrac closed this as completed Apr 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
👾 Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant