From b38077ff0fecee907d8b1338f904ccc97b9d0f2a Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 19 Aug 2014 20:03:36 -0700 Subject: [PATCH] New pkg/depcheck package to check Go version. Based on kr's example (syntantically valid Go code, to make cmd/go happy, but will fail to compile and include the failure text) Change-Id: I11f9eeabf6bf2c77055752014c71183b7eb7b23a --- pkg/blob/ref.go | 5 +++++ pkg/depcheck/depcheck.go | 19 +++++++++++++++++++ pkg/depcheck/min_go_version.go | 28 ++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 pkg/depcheck/depcheck.go create mode 100644 pkg/depcheck/min_go_version.go diff --git a/pkg/blob/ref.go b/pkg/blob/ref.go index 6035f940c..444a1f105 100644 --- a/pkg/blob/ref.go +++ b/pkg/blob/ref.go @@ -26,6 +26,11 @@ import ( "reflect" "regexp" "strings" + + // This is a pretty low-level package, so add the Go minimum + // version dependency check here at least. This avoids + // adding it in many other places. + _ "camlistore.org/pkg/depcheck" ) // Pattern is the regular expression which matches a blobref. diff --git a/pkg/depcheck/depcheck.go b/pkg/depcheck/depcheck.go new file mode 100644 index 000000000..d7f9a77ad --- /dev/null +++ b/pkg/depcheck/depcheck.go @@ -0,0 +1,19 @@ +/* +Copyright 2014 The Camlistore Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Package depcheck does nothing except for fail to build when +// the system's version of Go is too old. +package depcheck diff --git a/pkg/depcheck/min_go_version.go b/pkg/depcheck/min_go_version.go new file mode 100644 index 000000000..5c6d4f69f --- /dev/null +++ b/pkg/depcheck/min_go_version.go @@ -0,0 +1,28 @@ +// +build !go1.3 + +/* +Copyright 2014 The Camlistore Authors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package depcheck + +import ` + +**************************************************************************** + + Camlistore requires Go 1.3 or later. + +**************************************************************************** +`