package
1.0.3
Repository: https://github.com/cnjinhy/php-func-go.git
Documentation: pkg.go.dev

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
写入文件并返回写入的字节数.
使用 Golang 的 os 包获取文件的信息,包括文件大小,然后返回文件大小。如果文件不存在,则会返回一个错误。注意:由于 Golang 和 PHP 的权限模型略有不同,因此在某些情况下可能无法完全模拟 PHP 中 filesize() 函数的行为。.
No description provided by the author
由于math/rand包中生成的伪随机数是基于算法计算的,因此在特定的环境下,生成的随机数的最大值可能会是int32。On a stock installation as of version 7.4.33 / 8.1.12, this function seems to return 2147483647 (maximum 32-bit integer).
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
该函数使用了 Go 语言的 os.Stat 函数来获取文件信息,如果出现错误则返回 false,否则判断文件信息是否为目录类型,如果是,则返回 true,否则返回 false。需要注意的是,在 Go 中,目录和文件都是用 os.FileInfo 类型来表示的,因此我们需要使用 IsDir 方法来判断文件类型是否为目录。同时,该函数的参数必须是一个有效的路径,否则会返回 false。This function uses the Go language's os.Stat function to obtain file information.
No description provided by the author
该函数的原理是使用 Golang 的 os 包检查文件是否存在。如果文件不存在,则会在检查文件是否可读之前返回 false。否则,它将尝试打开文件以进行读取操作,如果打开失败则返回 false,否则返回 true。注意:由于 Golang 和 PHP 的权限模型略有不同,因此在某些情况下可能无法完全模拟 PHP 中 is_readable() 函数的行为。The principle of this function is to use Golang's os package to check whether a file exists.If the file does not exist, it returns false before checking whether the file is readable.
No description provided by the author
No description provided by the author
我们使用time包获取当前时间,并将其作为种子创建一个新的随机数生成器。然后,我们使用rand.Int31()函数生成一个介于0和(2^31-1)之间的随机整数,将其转换为浮点数,并除以(2^31-1)得到0到1之间的随机小数,就像在PHP的lcg_value函数中一样。需要注意的是,Go中的伪随机数生成器并不完全相同于PHP中的线性同余生成器算法,因此它们生成的随机数序列可能不完全相同。We use the time package to retrieve the current time and use it as a seed to create a new random number generator.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
md5_file returns the MD5 hash of the contents of the file at the given path.
在 Golang 中,可以使用 time 包和 math 包来实现类似于 PHP 中的 microtime 函数。对于 PHP 中的 microtime 函数,其参数是可选的。如果不传递参数,则返回一个字符串,其中包含当前时间的微秒数和秒数;如果传递 true 参数,则返回当前时间的浮点数表示,精确到微秒。.
我们使用Go的rand包中的Seed()函数将当前时间作为随机数生成器的种子,并使用Intn()函数生成随机数。注意,由于Intn()函数返回的随机数不包括上限,所以我们需要将max参数增加1来确保生成的随机数落在指定的范围之内。We use the Seed() function in Go's rand package to seed the current time as a random number generator, and use the Intn() function to generate random numbers.Note that since the random number returned by the Intn() function does not include the upper limit, we need to increase the max parameter by 1 to ensure that the generated random number falls within the specified range.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
在 Golang 中,我们可以使用 time 包来实现类似 PHP 中的 time 函数。.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Constants

No description provided by the author