open-im-server/internal/rpc/user/service/data_provider_impl.go
truongpx-Mac 819a6e58ce update
2024-10-07 18:06:59 +07:00

19 lines
444 B
Go

package service
import (
"errors"
"math/rand"
)
// DataProviderImpl is the concrete implementation of the DataProvider interface.
type DataProviderImpl struct{}
// GetRandomNumber simulates fetching a random number between 0 and id.
func (d *DataProviderImpl) GetRandomNumber(id int) (int, error) {
if id < 0 {
return 0, errors.New("InvalidId")
}
// Simulate fetching a random number between 0 and id
return rand.Intn(id + 1), nil
}