It looks like you'll need to calculate it manually, and there are multiple ways to do this, depending on assumptions you can make about your data. If you really go this route, I'd strongly encourage you to also test against existing implementations - for example R's cor.test
-
to ensure that you're not doing something wrong.
Normality Assumption
If the observed values are each approximately normal, then the value

where r
is the calculated correlation coefficient and n
is the number of observations, will follow Student's t distribution with n-2
degrees of freedom. Hence, you can use Student's t distribution as implemented in GoNum to compute the p-value. This is what cor.test
in R does.
It should go something like (please note I've never used Go):
import (
"math"
"gonum.org/v1/gonum/stat/distuv"
)
func twoSidedPValue(r float64, n float64) float64 {
// compute the test stat
ts := r * math.Sqrt((n - 2) / (1 - r*r))
// make a Student's t with (n-2) d.f.
t := distuv.StudentsT{0, 1, (n-2), nil}
// compute the p-value
pval := 2 * t.CDF(-math.Abs(testStat))
return pval
}
Testing against R's cor.test
seems to match up.
Permutation Test
If your sampled variables are not each normal, then you can use a permutation test. Essentially, randomize your data and see how many times a random correlation matches or exceeds your observed one. If your test is two-sided (i.e., you had no principled assumptions about the correlation outcome), use the absolute values of the correlation for the test.
Test Details
The Inference section of the Wikipedia entry, "Pearson correlation coefficient", has details.