本文整理汇总了Golang中camlistore/org/pkg/osutil.GoPackagePath函数的典型用法代码示例。如果您正苦于以下问题:Golang GoPackagePath函数的具体用法?Golang GoPackagePath怎么用?Golang GoPackagePath使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GoPackagePath函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: doKeyStuff
func doKeyStuff(b *testing.B) keyStuff {
camliRootPath, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
b.Fatal("Package camlistore.org no found in $GOPATH or $GOPATH not defined")
}
secretRingFile := filepath.Join(camliRootPath, "pkg", "jsonsign", "testdata", "test-secring.gpg")
pubKey := `-----BEGIN PGP PUBLIC KEY BLOCK-----
xsBNBEzgoVsBCAC/56aEJ9BNIGV9FVP+WzenTAkg12k86YqlwJVAB/VwdMlyXxvi
bCT1RVRfnYxscs14LLfcMWF3zMucw16mLlJCBSLvbZ0jn4h+/8vK5WuAdjw2YzLs
WtBcjWn3lV6tb4RJz5gtD/o1w8VWxwAnAVIWZntKAWmkcChCRgdUeWso76+plxE5
aRYBJqdT1mctGqNEISd/WYPMgwnWXQsVi3x4z1dYu2tD9uO1dkAff12z1kyZQIBQ
rexKYRRRh9IKAayD4kgS0wdlULjBU98aeEaMz1ckuB46DX3lAYqmmTEL/Rl9cOI0
Enpn/oOOfYFa5h0AFndZd1blMvruXfdAobjVABEBAAE=
=28/7
-----END PGP PUBLIC KEY BLOCK-----`
return keyStuff{
secretRingFile: secretRingFile,
pubKey: pubKey,
pubKeyRef: blob.SHA1FromString(pubKey),
entityFetcher: &jsonsign.CachingEntityFetcher{
Fetcher: &jsonsign.FileEntityFetcher{File: secretRingFile},
},
}
}
示例2: gitShortlog
func gitShortlog() *exec.Cmd {
if !*gitContainer {
return exec.Command("/bin/bash", "-c", "git log | git shortlog -sen")
}
args := []string{"run", "--rm"}
if inProd {
args = append(args,
"-v", "/var/camweb:/var/camweb",
"--workdir="+prodSrcDir,
)
} else {
hostRoot, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
log.Fatal(err)
}
log.Printf("Using bind root of %q", hostRoot)
args = append(args,
"-v", hostRoot+":"+prodSrcDir,
"--workdir="+prodSrcDir,
)
}
args = append(args, "camlistore/git", "/bin/bash", "-c", "git log | git shortlog -sen")
cmd := exec.Command("docker", args...)
cmd.Stderr = os.Stderr
return cmd
}
示例3: TestExpansionsInHighlevelConfig
func TestExpansionsInHighlevelConfig(t *testing.T) {
camroot, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
t.Fatalf("failed to find camlistore.org GOPATH root: %v", err)
}
const keyID = "26F5ABDA"
os.Setenv("TMP_EXPANSION_TEST", keyID)
os.Setenv("TMP_EXPANSION_SECRING", filepath.Join(camroot, filepath.FromSlash("pkg/jsonsign/testdata/test-secring.gpg")))
// Setting CAMLI_CONFIG_DIR to avoid triggering failInTests in osutil.CamliConfigDir
defer os.Setenv("CAMLI_CONFIG_DIR", os.Getenv("CAMLI_CONFIG_DIR")) // restore after test
os.Setenv("CAMLI_CONFIG_DIR", "whatever")
conf, err := serverinit.Load([]byte(`
{
"auth": "localhost",
"listen": ":4430",
"https": false,
"identity": ["_env", "${TMP_EXPANSION_TEST}"],
"identitySecretRing": ["_env", "${TMP_EXPANSION_SECRING}"],
"googlecloudstorage": ":camlistore-dev-blobs",
"kvIndexFile": "/tmp/camli-index.kvdb"
}
`))
if err != nil {
t.Fatal(err)
}
got := fmt.Sprintf("%#v", conf)
if !strings.Contains(got, keyID) {
t.Errorf("Expected key %s in resulting low-level config. Got: %s", keyID, got)
}
}
示例4: setup
// setup checks if the camlistore root can be found,
// then sets up closureGitDir and destDir, and returns whether
// we should clone or update in closureGitDir (depending on
// if a .git dir was found).
func setup() string {
camliRootPath, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
log.Fatal("Package camlistore.org not found in $GOPATH (or $GOPATH not defined).")
}
destDir = filepath.Join(camliRootPath, "third_party", "closure", "lib")
closureGitDir = filepath.Join(camliRootPath, "tmp", "closure-lib")
op := "update"
_, err = os.Stat(closureGitDir)
if err != nil {
if os.IsNotExist(err) {
err = os.MkdirAll(closureGitDir, 0755)
if err != nil {
log.Fatalf("Could not create %v: %v", closureGitDir, err)
}
op = "clone"
} else {
log.Fatalf("Could not stat %v: %v", closureGitDir, err)
}
}
dotGitPath := filepath.Join(closureGitDir, ".git")
_, err = os.Stat(dotGitPath)
if err != nil {
if os.IsNotExist(err) {
op = "clone"
} else {
log.Fatalf("Could not stat %v: %v", dotGitPath, err)
}
}
return op
}
示例5: camliClosurePage
// camliClosurePage checks if filename is a .js file using closure
// and if yes, if it provides a page in the camlistore namespace.
// It returns that page name, or the empty string otherwise.
func camliClosurePage(filename string) string {
camliRootPath, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
return ""
}
fullpath := filepath.Join(camliRootPath, "server", "camlistored", "ui", filename)
f, err := os.Open(fullpath)
if err != nil {
return ""
}
defer f.Close()
br := bufio.NewReader(f)
for {
l, err := br.ReadString('\n')
if err != nil {
return ""
}
if !strings.HasPrefix(l, "goog.") {
continue
}
m := provCamliRx.FindStringSubmatch(l)
if m != nil {
return m[2]
}
}
return ""
}
示例6: fileList
// fileList parses deps.js from the closure repo, as well as the similar
// dependencies generated for the UI js files, and compiles the list of
// js files from the closure lib required for the UI.
func fileList() ([]string, error) {
camliRootPath, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
log.Fatal("Package camlistore.org not found in $GOPATH (or $GOPATH not defined).")
}
uiDir := filepath.Join(camliRootPath, "server", "camlistored", "ui")
closureDepsFile := filepath.Join(closureGitDir, "closure", "goog", "deps.js")
f, err := os.Open(closureDepsFile)
if err != nil {
return nil, err
}
defer f.Close()
allClosureDeps, err := closure.DeepParseDeps(f)
if err != nil {
return nil, err
}
uiDeps, err := closure.GenDeps(http.Dir(uiDir))
if err != nil {
return nil, err
}
_, requ, err := closure.ParseDeps(bytes.NewReader(uiDeps))
if err != nil {
return nil, err
}
nameDone := make(map[string]bool)
jsfilesDone := make(map[string]bool)
for _, deps := range requ {
for _, dep := range deps {
if _, ok := nameDone[dep]; ok {
continue
}
jsfiles := allClosureDeps[dep]
for _, filename := range jsfiles {
if _, ok := jsfilesDone[filename]; ok {
continue
}
jsfilesDone[filename] = true
}
nameDone[dep] = true
}
}
jsfiles := []string{
"AUTHORS",
"LICENSE",
"README",
filepath.Join("closure", "goog", "base.js"),
filepath.Join("closure", "goog", "css", "common.css"),
filepath.Join("closure", "goog", "css", "toolbar.css"),
filepath.Join("closure", "goog", "deps.js"),
}
prefix := filepath.Join("closure", "goog")
for k, _ := range jsfilesDone {
jsfiles = append(jsfiles, filepath.Join(prefix, k))
}
sort.Strings(jsfiles)
return jsfiles, nil
}
示例7: main
func main() {
flag.Usage = usage
flag.Parse()
checkFlags()
camDir, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
log.Fatalf("Error looking up camlistore.org dir: %v", err)
}
dockDir = filepath.Join(camDir, "misc", "docker")
if *doBuildServer {
buildDockerImage("go", goDockerImage)
buildDockerImage("djpeg-static", djpegDockerImage)
// ctxDir is where we run "docker build" to produce the final
// "FROM scratch" Docker image.
ctxDir, err := ioutil.TempDir("", "camli-build")
if err != nil {
log.Fatal(err)
}
defer os.RemoveAll(ctxDir)
genCamlistore(ctxDir)
genDjpeg(ctxDir)
buildServer(ctxDir)
}
if *doUpload {
uploadDockerImage()
}
}
示例8: camSrcDir
func camSrcDir() string {
if inProd {
return prodSrcDir
}
dir, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
log.Fatalf("Failed to find the root of the Camlistore source code via osutil.GoPackagePath: %v", err)
}
return dir
}
示例9: fakePhoto
// TODO(mpl): refactor with twitter
func fakePhoto() string {
camliDir, err := osutil.GoPackagePath("camlistore.org")
if err == os.ErrNotExist {
log.Fatal("Directory \"camlistore.org\" not found under GOPATH/src; are you not running with devcam?")
}
if err != nil {
log.Fatalf("Error searching for \"camlistore.org\" under GOPATH: %v", err)
}
return filepath.Join(camliDir, filepath.FromSlash("third_party/glitch/npc_piggy__x1_walk_png_1354829432.png"))
}
示例10: camliSourceRoot
// CamliSourceRoot returns the root of the source tree, or an error.
func camliSourceRoot() (string, error) {
if os.Getenv("GOPATH") == "" {
return "", errors.New("GOPATH environment variable isn't set; required to run Camlistore integration tests")
}
root, err := osutil.GoPackagePath("camlistore.org")
if err == os.ErrNotExist {
return "", errors.New("Directory \"camlistore.org\" not found under GOPATH/src; can't run Camlistore integration tests.")
}
return root, nil
}
示例11: RunCommand
func (c *serverCmd) RunCommand(args []string) error {
err := c.checkFlags(args)
if err != nil {
return cmdmain.UsageError(fmt.Sprint(err))
}
c.camliSrcRoot, err = osutil.GoPackagePath("camlistore.org")
if err != nil {
return errors.New("Package camlistore.org not found in $GOPATH (or $GOPATH not defined).")
}
err = os.Chdir(c.camliSrcRoot)
if err != nil {
return fmt.Errorf("Could not chdir to %v: %v", c.camliSrcRoot, err)
}
if !c.noBuild {
for _, name := range []string{"camlistored", "camtool"} {
err := c.build(name)
if err != nil {
return fmt.Errorf("Could not build %v: %v", name, err)
}
}
}
if err := c.setCamliRoot(); err != nil {
return fmt.Errorf("Could not setup the camli root: %v", err)
}
if err := c.setEnvVars(); err != nil {
return fmt.Errorf("Could not setup the env vars: %v", err)
}
if err := c.setupIndexer(); err != nil {
return fmt.Errorf("Could not setup the indexer: %v", err)
}
if err := c.syncTemplateBlobs(); err != nil {
return fmt.Errorf("Could not copy the template blobs: %v", err)
}
if err := c.setFullClosure(); err != nil {
return fmt.Errorf("Could not setup the closure lib: %v", err)
}
log.Printf("Starting dev server on %v/ui/ with password \"pass%v\"\n",
os.Getenv("CAMLI_BASEURL"), c.port)
camliBin := filepath.Join(c.camliSrcRoot, "bin", "camlistored")
cmdArgs := []string{
"-configfile=" + filepath.Join(c.camliSrcRoot, "config", "dev-server-config.json"),
"-listen=" + c.listen}
cmd := exec.Command(camliBin, cmdArgs...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Start(); err != nil {
return fmt.Errorf("Could not start camlistored: %v", err)
}
go handleKillCamliSignal(cmd.Process)
cmd.Wait()
return nil
}
示例12: main
func main() {
flag.Usage = usage
flag.Parse()
checkFlags()
camDir, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
log.Fatalf("Error looking up camlistore.org dir: %v", err)
}
dockDir = filepath.Join(camDir, "misc", "docker")
if *doImage {
buildDockerImage("go", goDockerImage)
buildDockerImage("djpeg-static", djpegDockerImage)
// ctxDir is where we run "docker build" to produce the final
// "FROM scratch" Docker image.
ctxDir, err := ioutil.TempDir("", "camli-build")
if err != nil {
log.Fatal(err)
}
defer os.RemoveAll(ctxDir)
genCamlistore(ctxDir)
genDjpeg(ctxDir)
buildServer(ctxDir)
}
// TODO(mpl): maybe *doBinaries should be done by a separate go program,
// because the end product is not a docker image. However, we're still
// using docker all along, and it's convenient for now for code reuse. I
// can refactor it all out of dock.go afterwards if we like the process.
if *doBinaries {
// TODO(mpl): consider using an "official" or trusted existing
// Go docker image, since we don't do anything special anymore in
// ours?
buildDockerImage("go", goDockerImage+"-linux")
ctxDir, err := ioutil.TempDir("", "camli-build")
if err != nil {
log.Fatal(err)
}
defer os.RemoveAll(ctxDir)
genBinaries(ctxDir)
packBinaries(ctxDir)
}
if *doUpload {
if *doImage {
uploadDockerImage()
} else if *doBinaries {
uploadReleaseTarball()
}
}
}
示例13: TestQueryPermanodeLocation
func TestQueryPermanodeLocation(t *testing.T) {
testQuery(t, func(qt *queryTest) {
id := qt.id
p1 := id.NewPlannedPermanode("1")
p2 := id.NewPlannedPermanode("2")
p3 := id.NewPlannedPermanode("3")
id.SetAttribute(p1, "latitude", "51.5")
id.SetAttribute(p1, "longitude", "0")
id.SetAttribute(p2, "latitude", "51.5")
id.SetAttribute(p3, "longitude", "0")
p4 := id.NewPlannedPermanode("checkin")
p5 := id.NewPlannedPermanode("venue")
id.SetAttribute(p4, "camliNodeType", "foursquare.com:checkin")
id.SetAttribute(p4, "foursquareVenuePermanode", p5.String())
id.SetAttribute(p5, "latitude", "1.0")
id.SetAttribute(p5, "longitude", "2.0")
// Upload a basic image
camliRootPath, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
panic("Package camlistore.org no found in $GOPATH or $GOPATH not defined")
}
uploadFile := func(file string, modTime time.Time) blob.Ref {
fileName := filepath.Join(camliRootPath, "pkg", "search", "testdata", file)
contents, err := ioutil.ReadFile(fileName)
if err != nil {
panic(err)
}
br, _ := id.UploadFile(file, string(contents), modTime)
return br
}
fileRef := uploadFile("dude-gps.jpg", time.Time{})
p6 := id.NewPlannedPermanode("photo")
id.SetAttribute(p6, "camliContent", fileRef.String())
sq := &SearchQuery{
Constraint: &Constraint{
Permanode: &PermanodeConstraint{
Location: &LocationConstraint{
Any: true,
},
},
},
}
qt.wantRes(sq, p1, p4, p5, p6)
})
}
示例14: newTestServer
// newTestServer creates a new test server with in memory storage for use in upload tests
func newTestServer(t *testing.T) *httptest.Server {
camroot, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
t.Fatalf("failed to find camlistore.org GOPATH root: %v", err)
}
conf := serverconfig.Config{
Listen: ":3179",
HTTPS: false,
Auth: "localhost",
Identity: "26F5ABDA",
IdentitySecretRing: filepath.Join(camroot, filepath.FromSlash("pkg/jsonsign/testdata/test-secring.gpg")),
MemoryStorage: true,
MemoryIndex: true,
}
confData, err := json.MarshalIndent(conf, "", " ")
if err != nil {
t.Fatalf("Could not json encode config: %v", err)
}
// Setting CAMLI_CONFIG_DIR to avoid triggering failInTests in osutil.CamliConfigDir
defer os.Setenv("CAMLI_CONFIG_DIR", os.Getenv("CAMLI_CONFIG_DIR")) // restore after test
os.Setenv("CAMLI_CONFIG_DIR", "whatever")
lowConf, err := serverinit.Load(confData)
if err != nil {
t.Fatal(err)
}
// because these two are normally consumed in camlistored.go
// TODO(mpl): serverinit.Load should consume these 2 as well. Once
// consumed, we should keep all the answers as private fields, and then we
// put accessors on serverinit.Config. Maybe we even stop embedding
// jsonconfig.Obj in serverinit.Config too, so none of those methods are
// accessible.
lowConf.OptionalBool("https", true)
lowConf.OptionalString("listen", "")
reindex := false
var context *http.Request // only used by App Engine. See handlerLoader in serverinit.go
hi := http.NewServeMux()
address := "http://" + conf.Listen
_, err = lowConf.InstallHandlers(hi, address, reindex, context)
if err != nil {
t.Fatal(err)
}
return httptest.NewServer(hi)
}
示例15: startEmailCommitLoop
func startEmailCommitLoop(errc chan<- error) {
if *emailsTo == "" {
return
}
if *emailNow != "" {
dir, err := osutil.GoPackagePath("camlistore.org")
if err != nil {
log.Fatal(err)
}
if err := emailCommit(dir, *emailNow); err != nil {
log.Fatal(err)
}
os.Exit(0)
}
go func() {
errc <- commitEmailLoop()
}()
}