Skip to content

Use client with timeout instead of go DefaultClient #478

@becheran

Description

@becheran

Telebot will use the DefaultClient from the golang http lib if no client is explicitly passed.

As many others have already noticed, using the default client in go can be dangerous since no timeout is defined. See for example: https://medium.com/@nate510/don-t-use-go-s-default-http-client-4804cb19f779

I know that it's up to the user to pass a client to the constructor, though I think it might make sense to either use a client with a timeout in the example readme, or use a custom client as default if non is provided. Such as:

 &http.Client{
	Timeout: time.Second * 30,
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions