Skip to content

Commit

Permalink
Update Go version to 1.19 and update Go dependencies
Browse files Browse the repository at this point in the history
Go DP Lib:
* Implement mean and variance functions for testing.
* Use Go version 1.19
* Update dependencies

Privacy-on-Beam:
* Use Go version 1.19
* Update dependencies

Change-Id: I7f0324ce95ecc0e6422bbaa4b2f97fc31af93f03
GitOrigin-RevId: 350a2920fcc4a4b8310f34d54f40ae7ca1db1fbe
  • Loading branch information
Differential Privacy Team authored and dibakch committed Apr 13, 2023
1 parent cc0468a commit 59ba889
Show file tree
Hide file tree
Showing 24 changed files with 786 additions and 600 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
go-version: 1.19

- name: Build go
run: go build -mod=mod -v ./...
Expand Down
14 changes: 7 additions & 7 deletions examples/go/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "448e37e0dbf61d6fa8f00aaa12d191745e14f07c31cabfa731f0c8e8a4f41b97",
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
],
)

Expand All @@ -48,7 +48,7 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.18.3")
go_register_toolchains(version = "1.19.5")

# Load Go DP Library dependencies.
load("@com_github_google_differential_privacy_go_v2//:go_differential_privacy_deps.bzl", "go_differential_privacy_deps")
Expand Down
8 changes: 4 additions & 4 deletions examples/go/deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def go_differential_privacy_examples_deps():
go_repository(
name = "com_github_golang_glog",
importpath = "github.com/golang/glog",
sum = "h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=",
version = "v1.0.0",
sum = "h1:jxpi2eWoU84wbX9iIEyAeeoac3FLuifZpY9tcNUD9kw=",
version = "v1.1.1",
)
go_repository(
name = "com_github_google_go_cmp",
Expand Down Expand Up @@ -89,8 +89,8 @@ def go_differential_privacy_examples_deps():
go_repository(
name = "org_golang_x_exp",
importpath = "golang.org/x/exp",
sum = "h1:fiNkyhJPUvxbRPbCqY/D9qdjmPzfHcpK3P4bM4gioSY=",
version = "v0.0.0-20230118134722-a68e582fa157",
sum = "h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=",
version = "v0.0.0-20230321023759-10a507213a29",
)
go_repository(
name = "org_golang_x_image",
Expand Down
8 changes: 4 additions & 4 deletions examples/go/go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/google/differential-privacy/examples/go

go 1.18
go 1.19

require (
github.com/golang/glog v1.0.0
github.com/golang/glog v1.1.1
github.com/google/differential-privacy/go/v2 v2.0.0
)

require (
golang.org/x/exp v0.0.0-20230118134722-a68e582fa157 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
gonum.org/v1/gonum v0.12.0 // indirect
)
)
10 changes: 5 additions & 5 deletions examples/go/go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
github.com/golang/glog v1.1.1 h1:jxpi2eWoU84wbX9iIEyAeeoac3FLuifZpY9tcNUD9kw=
github.com/golang/glog v1.1.1/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
github.com/google/differential-privacy/go/v2 v2.0.0 h1:fpeIax4LoJiUmz0p6+Emn5M+Q4dmjEH2tAsC9OEVsD8=
github.com/google/differential-privacy/go/v2 v2.0.0/go.mod h1:5uMiDdXR2Mf0QT6xhtFIicXU0WQu2oVWjmKogBLrAQY=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/grd/stat v0.0.0-20130623202159-138af3fd5012 h1:TVY1GBBIAAph4RWO9Y3p1wU+7n6khY1jxPKjDphzznA=
golang.org/x/exp v0.0.0-20230118134722-a68e582fa157 h1:fiNkyhJPUvxbRPbCqY/D9qdjmPzfHcpK3P4bM4gioSY=
golang.org/x/exp v0.0.0-20230118134722-a68e582fa157/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
gonum.org/v1/gonum v0.12.0 h1:xKuo6hzt+gMav00meVPUlXwSdoEJP46BR+wdxQEFK2o=
gonum.org/v1/gonum v0.12.0/go.mod h1:73TDxJfAAHeA8Mk9mf8NlIppyhQNo5GLTcYeqgo2lvY=
gonum.org/v1/gonum v0.12.0/go.mod h1:73TDxJfAAHeA8Mk9mf8NlIppyhQNo5GLTcYeqgo2lvY=
24 changes: 12 additions & 12 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ use [Gazelle](https://github.com/bazelbuild/bazel-gazelle):
http_archive(
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
],
)
http_archive(
name = "bazel_gazelle",
sha256 = "448e37e0dbf61d6fa8f00aaa12d191745e14f07c31cabfa731f0c8e8a4f41b97",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
],
)
http_archive(
name = "bazel_gazelle",
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
],
)
http_archive(
name = "com_google_protobuf",
Expand All @@ -82,7 +82,7 @@ use [Gazelle](https://github.com/bazelbuild/bazel-gazelle):
go_rules_dependencies()
go_register_toolchains(version = "1.18.3")
go_register_toolchains(version = "1.19.5")
# Protobuf transitive dependencies.
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")
Expand Down
14 changes: 7 additions & 7 deletions go/WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "099a9fb96a376ccbbb7d291ed4ecbdfd42f6bc822ab77ae6f1b5cb9e914e94fa",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.35.0/rules_go-v0.35.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "448e37e0dbf61d6fa8f00aaa12d191745e14f07c31cabfa731f0c8e8a4f41b97",
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.28.0/bazel-gazelle-v0.28.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
],
)

Expand All @@ -41,7 +41,7 @@ load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.18.3")
go_register_toolchains(version = "1.19.5")

load("//:go_differential_privacy_deps.bzl", "go_differential_privacy_deps")

Expand Down
2 changes: 1 addition & 1 deletion go/dpagg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ go_test(
deps = [
"//noise:go_default_library",
"//rand:go_default_library",
"//stattestutils:go_default_library",
"@com_github_google_go_cmp//cmp:go_default_library",
"@com_github_google_go_cmp//cmp/cmpopts:go_default_library",
"@com_github_grd_stat//:go_default_library",
],
)
9 changes: 5 additions & 4 deletions go/dpagg/count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"testing"

"github.com/google/differential-privacy/go/v2/noise"
"github.com/google/differential-privacy/go/v2/stattestutils"
"github.com/google/go-cmp/cmp"
"github.com/grd/stat"
)

func TestNewCount(t *testing.T) {
Expand Down Expand Up @@ -771,19 +771,20 @@ func TestCountIsUnbiased(t *testing.T) {
variance: 1.8, // approximated via a simulation
},
} {
countSamples := make(stat.IntSlice, numberOfSamples)
countSamples := make([]float64, numberOfSamples)
for i := 0; i < numberOfSamples; i++ {
count, err := NewCount(tc.opt)
if err != nil {
t.Fatalf("Couldn't initialize count: %v", err)
}
count.IncrementBy(tc.rawCount)
countSamples[i], err = count.Result()
intSample, err := count.Result()
if err != nil {
t.Fatalf("Couldn't compute dp result: %v", err)
}
countSamples[i] = float64(intSample)
}
sampleMean := stat.Mean(countSamples)
sampleMean := stattestutils.SampleMean(countSamples)
// Assuming that count is unbiased, each sample should have a mean of tc.rawCount
// and a variance of tc.variance. The resulting sampleMean is approximately Gaussian
// distributed with the same mean and a variance of tc.variance / numberOfSamples.
Expand Down
13 changes: 7 additions & 6 deletions go/dpagg/sum_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import (
"testing"

"github.com/google/differential-privacy/go/v2/noise"
"github.com/google/differential-privacy/go/v2/stattestutils"
"github.com/google/go-cmp/cmp"
"github.com/grd/stat"
)

func getNoiselessBSI(t *testing.T) *BoundedSumInt64 {
Expand Down Expand Up @@ -1861,19 +1861,20 @@ func TestBoundedSumInt64IsUnbiased(t *testing.T) {
variance: 1.8, // approximated via a simulation
},
} {
sumSamples := make(stat.IntSlice, numberOfSamples)
sumSamples := make([]float64, numberOfSamples)
for i := 0; i < numberOfSamples; i++ {
sum, err := NewBoundedSumInt64(tc.opt)
if err != nil {
t.Fatalf("Couldn't initialize sum: %v", err)
}
sum.Add(tc.rawEntry)
sumSamples[i], err = sum.Result()
intSample, err := sum.Result()
if err != nil {
t.Fatalf("Couldn't compute dp result: %v", err)
}
sumSamples[i] = float64(intSample)
}
sampleMean := stat.Mean(sumSamples)
sampleMean := stattestutils.SampleMean(sumSamples)
// Assuming that sum is unbiased, each sample should have a mean of tc.rawEntry
// and a variance of tc.variance. The resulting sampleMean is approximately Gaussian
// distributed with the same mean and a variance of tc.variance / numberOfSamples.
Expand Down Expand Up @@ -2040,7 +2041,7 @@ func TestBoundedSumFloat64IsUnbiased(t *testing.T) {
variance: 2.0 / (ln3 * ln3),
},
} {
sumSamples := make(stat.Float64Slice, numberOfSamples)
sumSamples := make([]float64, numberOfSamples)
for i := 0; i < numberOfSamples; i++ {
sum, err := NewBoundedSumFloat64(tc.opt)
if err != nil {
Expand All @@ -2052,7 +2053,7 @@ func TestBoundedSumFloat64IsUnbiased(t *testing.T) {
t.Fatalf("Couldn't compute dp result: %v", err)
}
}
sampleMean := stat.Mean(sumSamples)
sampleMean := stattestutils.SampleMean(sumSamples)
// Assuming that sum is unbiased, each sample should have a mean of tc.rawEntry
// and a variance of tc.variance. The resulting sampleMean is approximately Gaussian
// distributed with the same mean and a variance of tc.variance / numberOfSamples.
Expand Down
7 changes: 3 additions & 4 deletions go/go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
module github.com/google/differential-privacy/go/v2

go 1.18
go 1.19

require (
github.com/golang/glog v1.0.0
github.com/golang/glog v1.1.1
github.com/google/go-cmp v0.5.9
github.com/grd/stat v0.0.0-20130623202159-138af3fd5012
gonum.org/v1/gonum v0.12.0
)

require golang.org/x/exp v0.0.0-20230118134722-a68e582fa157 // indirect
require golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
12 changes: 5 additions & 7 deletions go/go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=
github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4=
github.com/golang/glog v1.1.1 h1:jxpi2eWoU84wbX9iIEyAeeoac3FLuifZpY9tcNUD9kw=
github.com/golang/glog v1.1.1/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/grd/stat v0.0.0-20130623202159-138af3fd5012 h1:TVY1GBBIAAph4RWO9Y3p1wU+7n6khY1jxPKjDphzznA=
github.com/grd/stat v0.0.0-20130623202159-138af3fd5012/go.mod h1:hHyH5N67TF4tD4PBbqMlyuIu5Lq5QwKSgNyyG31trzY=
golang.org/x/exp v0.0.0-20230118134722-a68e582fa157 h1:fiNkyhJPUvxbRPbCqY/D9qdjmPzfHcpK3P4bM4gioSY=
golang.org/x/exp v0.0.0-20230118134722-a68e582fa157/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
gonum.org/v1/gonum v0.12.0 h1:xKuo6hzt+gMav00meVPUlXwSdoEJP46BR+wdxQEFK2o=
gonum.org/v1/gonum v0.12.0/go.mod h1:73TDxJfAAHeA8Mk9mf8NlIppyhQNo5GLTcYeqgo2lvY=
gonum.org/v1/gonum v0.12.0/go.mod h1:73TDxJfAAHeA8Mk9mf8NlIppyhQNo5GLTcYeqgo2lvY=
14 changes: 4 additions & 10 deletions go/go_differential_privacy_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,15 @@ def go_differential_privacy_deps():
go_repository(
name = "com_github_golang_glog",
importpath = "github.com/golang/glog",
sum = "h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ=",
version = "v1.0.0",
sum = "h1:jxpi2eWoU84wbX9iIEyAeeoac3FLuifZpY9tcNUD9kw=",
version = "v1.1.1",
)
go_repository(
name = "com_github_google_go_cmp",
importpath = "github.com/google/go-cmp",
sum = "h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=",
version = "v0.5.9",
)
go_repository(
name = "com_github_grd_stat",
importpath = "github.com/grd/stat",
sum = "h1:TVY1GBBIAAph4RWO9Y3p1wU+7n6khY1jxPKjDphzznA=",
version = "v0.0.0-20130623202159-138af3fd5012",
)

go_repository(
name = "ht_sr_git_sbinet_gg",
Expand All @@ -91,8 +85,8 @@ def go_differential_privacy_deps():
go_repository(
name = "org_golang_x_exp",
importpath = "golang.org/x/exp",
sum = "h1:fiNkyhJPUvxbRPbCqY/D9qdjmPzfHcpK3P4bM4gioSY=",
version = "v0.0.0-20230118134722-a68e582fa157",
sum = "h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=",
version = "v0.0.0-20230321023759-10a507213a29",
)
go_repository(
name = "org_golang_x_image",
Expand Down
2 changes: 1 addition & 1 deletion go/noise/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,5 @@ go_test(
"secure_noise_math_test.go",
],
embed = [":go_default_library"],
deps = ["@com_github_grd_stat//:go_default_library"],
deps = ["//stattestutils:go_default_library"],
)
Loading

0 comments on commit 59ba889

Please sign in to comment.