github.com/joshdk/godel@v0.0.0-20170529232908-862138a45aee/cmd/packages/packages.go (about) 1 // Copyright 2016 Palantir Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package packages 16 17 import ( 18 "github.com/palantir/pkg/matcher" 19 "github.com/palantir/pkg/pkgpath" 20 "github.com/pkg/errors" 21 ) 22 23 func List(exclude matcher.Matcher, wd string) ([]string, error) { 24 pkgs, err := pkgpath.PackagesInDir(wd, exclude) 25 if err != nil { 26 return nil, errors.Wrapf(err, "Failed to list packages") 27 } 28 29 pkgPaths, err := pkgs.Paths(pkgpath.Relative) 30 if err != nil { 31 return nil, errors.Wrapf(err, "Failed to get package paths") 32 } 33 34 return pkgPaths, nil 35 }