golang rand()是否使用libc rand()

I use same seed in golang and C,but get different rand number I know php use libc rand(),how about golang?

//golang:
rand.Seed(12345); 
rand.Uint32();

//C:
srand(12345); 
rand();

No, the rand package doesn't use the C standard library at all, which you can tell by looking at each source file to see that it doesn't use CGO.

Does golang rand() use libc rand()

No.

The C standard imposes limited requirements on the behaviour of rand() - what you typically get is a linear congruential generator with a reasonable periodicity (related to RAND_MAX) and srand allows you to seed that generator.

So there's no reason why it would return the same series as another linear congruential generator or otherwise, even with the same starting seed.

If you want your inter-language generators to match, then you might want to roll your own.

I have implemented function rand and srand by golang. It can get same result compared to PHP/C.

package fcrypt

var index int
var r []int

func mysrand(seed int) {
    r = append(r, seed)
    for i := 1; i < 31; i++ {
        r = append(r, (16807*r[i-1])%2147483647)
        if r[i] < 0 {
            r[i] = r[i] + 2147483647
        }
    }
    for i := 31; i < 34; i++ {
        r = append(r, r[i-31])
    }
    for i := 34; i < 344; i++ {
        r = append(r, r[i-31]+r[i-3])
    }
}
func myrand() uint32 {
    i := 344 + index
    r = append(r, r[i-31]+r[i-3])
    index = index + 1
    return uint32(r[i]) >> 1
}