From 20745492ba3471f7ae4b2e86ed5d2e5953068918 Mon Sep 17 00:00:00 2001 From: James Ross Date: Mon, 12 Sep 2022 12:48:53 -0700 Subject: [PATCH] Move to internal/generated_src --- .../github.com/palantir/outparamcheck/main.go | 29 ------------- .../outparamcheck/outparamcheck/config.go | 16 ------- godel/config/amalgomate-plugin.yml | 2 +- godel/config/godel.yml | 2 +- .../generated_src}/amalgomatedcheck.go | 16 ++++++- .../amalgomated_flag/example_func_test.go | 14 ++++++ .../internal/amalgomated_flag/example_test.go | 14 ++++++ .../amalgomated_flag/example_textvar_test.go | 14 ++++++ .../amalgomated_flag/example_value_test.go | 14 ++++++ .../internal/amalgomated_flag/export_test.go | 14 ++++++ .../internal/amalgomated_flag/flag.go | 14 ++++++ .../internal/amalgomated_flag/flag_test.go | 14 ++++++ .../github.com/palantir/outparamcheck/main.go | 43 +++++++++++++++++++ .../outparamcheck/outparamcheck/config.go | 30 +++++++++++++ .../outparamcheck/outparamcheck/error.go | 14 ++++++ .../outparamcheck/outparamcheck.go | 14 ++++++ main.go | 2 +- 17 files changed, 217 insertions(+), 49 deletions(-) delete mode 100644 generated_src/internal/github.com/palantir/outparamcheck/main.go delete mode 100644 generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/config.go rename {generated_src => internal/generated_src}/amalgomatedcheck.go (52%) rename {generated_src => internal/generated_src}/internal/amalgomated_flag/example_func_test.go (62%) rename {generated_src => internal/generated_src}/internal/amalgomated_flag/example_test.go (81%) rename {generated_src => internal/generated_src}/internal/amalgomated_flag/example_textvar_test.go (58%) rename {generated_src => internal/generated_src}/internal/amalgomated_flag/example_value_test.go (58%) rename {generated_src => internal/generated_src}/internal/amalgomated_flag/export_test.go (51%) rename {generated_src => internal/generated_src}/internal/amalgomated_flag/flag.go (98%) rename {generated_src => internal/generated_src}/internal/amalgomated_flag/flag_test.go (97%) create mode 100644 internal/generated_src/internal/github.com/palantir/outparamcheck/main.go create mode 100644 internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/config.go rename {generated_src => internal/generated_src}/internal/github.com/palantir/outparamcheck/outparamcheck/error.go (66%) rename {generated_src => internal/generated_src}/internal/github.com/palantir/outparamcheck/outparamcheck/outparamcheck.go (91%) diff --git a/generated_src/internal/github.com/palantir/outparamcheck/main.go b/generated_src/internal/github.com/palantir/outparamcheck/main.go deleted file mode 100644 index f570b9aa..00000000 --- a/generated_src/internal/github.com/palantir/outparamcheck/main.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 Palantir Technologies, Inc. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root -// for license information. - -package amalgomated - -import ( - "github.com/palantir/godel-okgo-asset-outparamcheck/generated_src/internal/amalgomated_flag" - "fmt" - "os" - "runtime" - - "github.com/palantir/godel-okgo-asset-outparamcheck/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck" -) - -func AmalgomatedMain() { - runtime.GOMAXPROCS(runtime.NumCPU()) - - cfgPath := "" - fset := flag.CommandLine - fset.StringVar(&cfgPath, "config", "", "JSON configuration or '@' followed by path to a configuration file (@pathToJsonFile)") - flag.Parse() - - err := outparamcheck.Run(cfgPath, flag.Args()) - if err != nil { - fmt.Fprintln(os.Stderr, err) - os.Exit(1) - } -} diff --git a/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/config.go b/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/config.go deleted file mode 100644 index eb9cfbb2..00000000 --- a/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/config.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2016 Palantir Technologies, Inc. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root -// for license information. - -package outparamcheck - -// Config stores a map from function name to the argument indices which are output parameters. -type Config map[string][]int - -var defaultCfg = Config( - map[string][]int{ - "encoding/json.Unmarshal": {1}, - "encoding/safejson.Unmarshal": {1}, - "gopkg.in/yaml.v2.Unmarshal": {1}, - }, -) diff --git a/godel/config/amalgomate-plugin.yml b/godel/config/amalgomate-plugin.yml index 0699a0c1..0bc23851 100644 --- a/godel/config/amalgomate-plugin.yml +++ b/godel/config/amalgomate-plugin.yml @@ -1,5 +1,5 @@ amalgomators: outparamcheck: config: check.yml - output-dir: generated_src + output-dir: internal/generated_src pkg: amalgomatedcheck diff --git a/godel/config/godel.yml b/godel/config/godel.yml index f296abd7..281026c5 100644 --- a/godel/config/godel.yml +++ b/godel/config/godel.yml @@ -19,6 +19,6 @@ exclude: names: - \..+ - vendor - - generated_src + - internal/generated_src paths: - godel diff --git a/generated_src/amalgomatedcheck.go b/internal/generated_src/amalgomatedcheck.go similarity index 52% rename from generated_src/amalgomatedcheck.go rename to internal/generated_src/amalgomatedcheck.go index 4586215e..5e97ec36 100644 --- a/generated_src/amalgomatedcheck.go +++ b/internal/generated_src/amalgomatedcheck.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // generated by amalgomate; DO NOT EDIT package amalgomatedcheck @@ -5,7 +19,7 @@ import ( "fmt" "sort" - outparamcheck "github.com/palantir/godel-okgo-asset-outparamcheck/generated_src/internal/github.com/palantir/outparamcheck" + outparamcheck "github.com/palantir/godel-okgo-asset-outparamcheck/internal/generated_src/internal/github.com/palantir/outparamcheck" ) var programs = map[string]func(){"outparamcheck": func() { diff --git a/generated_src/internal/amalgomated_flag/example_func_test.go b/internal/generated_src/internal/amalgomated_flag/example_func_test.go similarity index 62% rename from generated_src/internal/amalgomated_flag/example_func_test.go rename to internal/generated_src/internal/amalgomated_flag/example_func_test.go index 7c30c5e7..ad06d25d 100644 --- a/generated_src/internal/amalgomated_flag/example_func_test.go +++ b/internal/generated_src/internal/amalgomated_flag/example_func_test.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // Copyright 2020 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/generated_src/internal/amalgomated_flag/example_test.go b/internal/generated_src/internal/amalgomated_flag/example_test.go similarity index 81% rename from generated_src/internal/amalgomated_flag/example_test.go rename to internal/generated_src/internal/amalgomated_flag/example_test.go index 04a0d20e..30755677 100644 --- a/generated_src/internal/amalgomated_flag/example_test.go +++ b/internal/generated_src/internal/amalgomated_flag/example_test.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // Copyright 2012 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/generated_src/internal/amalgomated_flag/example_textvar_test.go b/internal/generated_src/internal/amalgomated_flag/example_textvar_test.go similarity index 58% rename from generated_src/internal/amalgomated_flag/example_textvar_test.go rename to internal/generated_src/internal/amalgomated_flag/example_textvar_test.go index 8b8cbf6b..0afafaea 100644 --- a/generated_src/internal/amalgomated_flag/example_textvar_test.go +++ b/internal/generated_src/internal/amalgomated_flag/example_textvar_test.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // Copyright 2022 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/generated_src/internal/amalgomated_flag/example_value_test.go b/internal/generated_src/internal/amalgomated_flag/example_value_test.go similarity index 58% rename from generated_src/internal/amalgomated_flag/example_value_test.go rename to internal/generated_src/internal/amalgomated_flag/example_value_test.go index 9d464c62..7ef53843 100644 --- a/generated_src/internal/amalgomated_flag/example_value_test.go +++ b/internal/generated_src/internal/amalgomated_flag/example_value_test.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // Copyright 2018 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/generated_src/internal/amalgomated_flag/export_test.go b/internal/generated_src/internal/amalgomated_flag/export_test.go similarity index 51% rename from generated_src/internal/amalgomated_flag/export_test.go rename to internal/generated_src/internal/amalgomated_flag/export_test.go index 9ef93ed6..caac2315 100644 --- a/generated_src/internal/amalgomated_flag/export_test.go +++ b/internal/generated_src/internal/amalgomated_flag/export_test.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // Copyright 2010 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/generated_src/internal/amalgomated_flag/flag.go b/internal/generated_src/internal/amalgomated_flag/flag.go similarity index 98% rename from generated_src/internal/amalgomated_flag/flag.go rename to internal/generated_src/internal/amalgomated_flag/flag.go index 9abf8d76..b99fcc98 100644 --- a/generated_src/internal/amalgomated_flag/flag.go +++ b/internal/generated_src/internal/amalgomated_flag/flag.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/generated_src/internal/amalgomated_flag/flag_test.go b/internal/generated_src/internal/amalgomated_flag/flag_test.go similarity index 97% rename from generated_src/internal/amalgomated_flag/flag_test.go rename to internal/generated_src/internal/amalgomated_flag/flag_test.go index ca6ba5d1..26a92b81 100644 --- a/generated_src/internal/amalgomated_flag/flag_test.go +++ b/internal/generated_src/internal/amalgomated_flag/flag_test.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. diff --git a/internal/generated_src/internal/github.com/palantir/outparamcheck/main.go b/internal/generated_src/internal/github.com/palantir/outparamcheck/main.go new file mode 100644 index 00000000..d9169586 --- /dev/null +++ b/internal/generated_src/internal/github.com/palantir/outparamcheck/main.go @@ -0,0 +1,43 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + +// Copyright 2016 Palantir Technologies, Inc. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root +// for license information. + +package amalgomated + +import ( + "github.com/palantir/godel-okgo-asset-outparamcheck/internal/generated_src/internal/amalgomated_flag" + "fmt" + "os" + "runtime" + + "github.com/palantir/godel-okgo-asset-outparamcheck/internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck" +) + +func AmalgomatedMain() { + runtime.GOMAXPROCS(runtime.NumCPU()) + + cfgPath := "" + fset := flag.CommandLine + fset.StringVar(&cfgPath, "config", "", "JSON configuration or '@' followed by path to a configuration file (@pathToJsonFile)") + flag.Parse() + + err := outparamcheck.Run(cfgPath, flag.Args()) + if err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} diff --git a/internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/config.go b/internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/config.go new file mode 100644 index 00000000..d954ded5 --- /dev/null +++ b/internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/config.go @@ -0,0 +1,30 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + +// Copyright 2016 Palantir Technologies, Inc. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root +// for license information. + +package outparamcheck + +// Config stores a map from function name to the argument indices which are output parameters. +type Config map[string][]int + +var defaultCfg = Config( + map[string][]int{ + "encoding/json.Unmarshal": {1}, + "encoding/safejson.Unmarshal": {1}, + "gopkg.in/yaml.v2.Unmarshal": {1}, + }, +) diff --git a/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/error.go b/internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/error.go similarity index 66% rename from generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/error.go rename to internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/error.go index 5d83e51c..017498e5 100644 --- a/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/error.go +++ b/internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/error.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // Copyright 2013 Kamil Kisiel // Modifications copyright 2016 Palantir Technologies, Inc. // Licensed under the MIT License. See LICENSE in the project root diff --git a/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/outparamcheck.go b/internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/outparamcheck.go similarity index 91% rename from generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/outparamcheck.go rename to internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/outparamcheck.go index 18ba10e3..ce7a2a74 100644 --- a/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/outparamcheck.go +++ b/internal/generated_src/internal/github.com/palantir/outparamcheck/outparamcheck/outparamcheck.go @@ -1,3 +1,17 @@ +// Copyright 2022 Palantir Technologies, Inc. +// +// 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. + // Copyright 2013 Kamil Kisiel // Modifications copyright 2016 Palantir Technologies, Inc. // Licensed under the MIT License. See LICENSE in the project root diff --git a/main.go b/main.go index 25636825..237cd8a0 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ import ( "os" "github.com/palantir/amalgomate/amalgomated" - amalgomatedcheck "github.com/palantir/godel-okgo-asset-outparamcheck/generated_src" + amalgomatedcheck "github.com/palantir/godel-okgo-asset-outparamcheck/internal/generated_src" "github.com/palantir/godel-okgo-asset-outparamcheck/outparamcheck/config" "github.com/palantir/godel-okgo-asset-outparamcheck/outparamcheck/creator" "github.com/palantir/okgo/checker"