当前位置:网站首页>Golang invalid argument to INTN
Golang invalid argument to INTN
2022-07-23 21:46:00 【CmderQ】
One The problem background
Recent projects , Because we have to deal with random problems , So use random numbers . The project is in the process of testing , Suddenly reported a mistake :invalid argument to intn; The tips are as follows :

Two The cause of the problem
The random function I use here , yes golang Built in bag rand, The way to do it is rand.Intn, The input parameter of this method is a non negative number ; Then the return value is [0,n) Random number between ; When I use it , No input parameter n Judge , In some cases , Enter the reference n Will become 0, That is why the above error report :invalid argument to intn
in fact , This error is the prompt in the source code implementation of random functions ; When the passed in parameter is less than or equal to 0 when , You're going to throw this hint ; example demo as follows :
package main
import (
"fmt"
"math/rand"
边栏推荐
- U++ learning notes control object scale
- Uncertainty of distributed energy - wind speed test (realized by matlab code)
- SQL注入攻击
- Kuberntes云原生实战六 使用Rook搭建Ceph集群
- 合宙ESP32C3硬件配置信息串口打印输出
- 机器学习习题——对率回归
- Comparison of open source distributed link tracking
- Quick review of interview (III): probability theory and mathematical statistics
- lambda學習(sort後面的Comparator的使用,collection後使用Collectors.groupingBy分組)
- 实时监控Mysql数据库变化_进行数据同步_了解Canal_---Canal工作笔记001
猜你喜欢

Lambda learning (the use of comparator after sort and collectors.groupingby after collection)
![[complex overloaded operator]](/img/ff/aafaa9471a1bd6ef57f6a619449e80.png)
[complex overloaded operator]

Protocol buffers 的问题和滥用
![[isprint function determines whether characters can be output]](/img/c8/c06dc36dbd0bf1feeba64c7753faf5.png)
[isprint function determines whether characters can be output]

Openlayers instance accessible map accessible map

Chapter1 data cleaning

Cluster chat server: cluster and distributed theory

Cluster chat server: Design of database table

合宙ESP32C3硬件配置信息串口打印输出

【HiFlow】腾讯云新一代自动化助手,我用它完成了企业疫情提示(无代码)
随机推荐
C——文件
Yushu A1 robot dog gesture control
Problems and abuse of protocol buffers
TreeMap
程序员成长第二十六篇:如何开好每日晨会?
集群聊天服务器:工程目录的创建
U++ 事件
Basic character axis binding and mapping binding of u++ learning notes
googletest
MySQL数据库索引
Unity - 3D mathematics -vector3
如何在 pyqt 中实现桌面歌词
query中的customer exit客户出口变量
Sword finger offer Second Edition: string (simple)
Scala programming (elementary)
uniapp使用canvas写环形进度条
BroadCast(广播)
博客总排名为918
JS object array de duplication
Customer exit variable in query