{"id":24668856,"url":"https://github.com/linuxerwang/goplz","last_synced_at":"2025-03-21T13:25:11.069Z","repository":{"id":57533207,"uuid":"251122613","full_name":"linuxerwang/goplz","owner":"linuxerwang","description":"goplz is a tool to help Go developers use Please build tool with a more flexible source file layout.","archived":false,"fork":false,"pushed_at":"2021-12-31T17:41:05.000Z","size":29,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-26T09:17:43.750Z","etag":null,"topics":["build-tool","go","please"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/linuxerwang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-03-29T20:03:05.000Z","updated_at":"2024-09-10T19:40:39.000Z","dependencies_parsed_at":"2022-09-26T18:20:56.795Z","dependency_job_id":null,"html_url":"https://github.com/linuxerwang/goplz","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxerwang%2Fgoplz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxerwang%2Fgoplz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxerwang%2Fgoplz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/linuxerwang%2Fgoplz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/linuxerwang","download_url":"https://codeload.github.com/linuxerwang/goplz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244804632,"owners_count":20513148,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build-tool","go","please"],"created_at":"2025-01-26T09:17:47.452Z","updated_at":"2025-03-21T13:25:11.043Z","avatar_url":"https://github.com/linuxerwang.png","language":"Go","readme":"# goplz\n\n## Overview\n\ngoplz is a tool to help Go developers use [Please](https://please.build/) build\ntool with a more flexible source file layout.\n\nOrganizing multi-project source file layout is not a trivial thing. Build tools\nlike Bazel, Buck, and Please provide excellent supports to layout your source\nfiles the way it makes sense to your organization. However, for Go developers,\nsince Go has its own source file layout and most Go dev tools are designed on\ntop of this layout, it's not trivial to make both the build tools and the dev\ntools to work together.\n\nFor example, some companies mandates a single source layout with a single src:\n\n```\n$TOP/ (GOPATH)\n  |- src/\n      |- mycompany.com/\n           |- accounts/\n                |- account.go\n           |- orders/\n           |- payments/\n```\n\nIt's super simple and works for both build tools and Go dev tools. However, it\nwill be awkward if you company also has non-Go projects. Cluttering projects\nwith different language makes the layout a mess, and sometimes you might be\nforced to drop this layout. Another problem is this layout is only suitable when\nthe whole source tree fits in one repository. For companies with huge number of\nprojects it's not applicable.\n\nTherefore, the following source file layout might be more attractive:\n\n```\n$TOP/ (Go import path: mycompany.com)\n  |- accounts/\n       |- account.go\n  |- orders/\n  |- payments/\n```\n\nThe benefits are:\n\n- Projects are closer to top directory thus easier to find and more pleasant to\n\twork with.\n- Code for a specific project can be concentrated in one directory tree.\n- It doesn't mandate a Go source code layout, thus projects with other languages\n\tcan fit in.\n- The Please build tool supports this layout (in .plzconfig the \"Go\" section\n\ta ImportPath can be set).\n- Cross referencing among projects are more natual. For example in\n\tpayments/BUILD.plz:\n\n\t```python\n\tgo_library(\n\t\tname = \"payments\",\n\t\tdeps = [\n\t\t\t\"//accounts/user:user\",\n\t\t],\n\t)\n\t```\n\nHowever, if you take this kind of source file layout, it will be hard to make\nGo dev tools work, since these tools are based on the Go source file layout.\nMost of the time, you need to use symlinks and environments to make the Go\ntoolchain happy.\n\nThis is exactly why goplz is created. It utilizes the linux FUSE library and\nmaps the Please source code layout to Go's standard layout, so that Go\ndevelopers can take advantage of both Go tools and Please.\n\nIt's a re-implementation of [gobazel](https://github.com/linuxerwang/gobazel)\nfor Please and has the same limit that it only works for Linux and MacOS users).\n\n## Get goplz\n\n### Install prebuilt package\n\nUbuntu users can also download the deb package in the release tab.\n\n### Build from source code\n\ngoplz is built with Please.\n\nSuppose you have a normal Go SDK, run the following command to get goplz source\ncode:\n\n```bash\n$ go get -d https://github.com/linuxerwang/goplz\n```\n\nIn goplz folder, run \"plz build\":\n\n```bash\n$ plz build :goplz\n```\n\nPut the executable file \"goplz\" in your $PATH or anywhere you know how to\naccess.\n\n## Using goplz\n\n### Setup .plzconfig\n\nFirst, you must already have a source file tree with Please as build tool.\nThe goplz repository itself is a good example. Note that you should have a\n.plzconfig file with ImportPath set up:\n\n```ini\n; Please config file\n; Leaving this file as is is enough to use plz to build your project.\n; Please will stay on whatever version you currently have until you run\n; 'plz update', when it will download the latest available version.\n;\n; Or you can uncomment the following to pin everyone to a particular version;\n; when you change it all users will automatically get updated.\n; [please]\n; version = 14.1.12\n\n[go]\nImportPath = github.com/linuxerwang/goplz\n```\n\nFor example, if you folder is at ~/tmp/goplz, run this command:\n\n```bash\n$ plz init\n```\n\nYou need to add ImportPath manually.\n\n### Setup goplz\n\nNext, in ~/tmp/goplz run the \"goplz init\" command:\n\n```bash\n$ goplz init\nInitialized goplz, the virtual GOPATH is at /home/ubuntu/tmp/.goplz-gopath.\nNow you can run `goplz start`.\n```\n\nThe init command creates a .goplzrc file in the top folder, which sets up\nVS Code as default editor. You can change it to whatever IDE you'd use.\n\nNow you can run the start command:\n\n```bash\n$ goplz start\n```\n\ngoplz starts a daemon program which creates a hidden folder .goplz-gopath, uses\nit as GOPATH, where your Go dev tools should point at, and uses FUSE library to\nmap your real source files into this virtual GOPATH on the fly.\n\nAlso, goplz starts the configured IDE for you, with the correct virtual GOPATH\nset correctly. Now ~/tmp/.goplz-gopath has the following standart Go structure:\n\n```\n.\n├── bin\n├── pkg\n└── src\n    └── github.com\n        └── linuxerwang\n            └── goplz\n                └── pleasew\n```\n\nFrom now on, you change your code only in ~/tmp/.goplz-gopath, but build\nyour code in ~/tmp/goplz. The Go language tools should work without problem\nin your IDE (autocomplete, go to definition, etc).\n\nTo stop goplz daemon, run:\n\n```bash\n$ goplz stop\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinuxerwang%2Fgoplz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flinuxerwang%2Fgoplz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flinuxerwang%2Fgoplz/lists"}