HOME, GOPATH and me

817b7699ccbd3a6664de66eee8c2cbd2?s=47 Yoji Shidara
January 21, 2015

HOME, GOPATH and me

Sapporo #golang Meetup
2015-01-21

817b7699ccbd3a6664de66eee8c2cbd2?s=128

Yoji Shidara

January 21, 2015
Tweet

Transcript

  1. )0.&ͱ(01"5)ͱࢲ
 —HOME, GOPATH and me ઃᒜ༸࣐
 !EBSBTIJ Sapporo #golang Meetup


    2015-01-21 5IFNBTDPUXBTEFTJHOFECZ3FOÉF'SFODI
 -JDFOTFEVOEFS$$#:
  2. l(PʹೖΓͯ͸(Pʹै͑z —Yoji Shidara, 7 Jul 2014. https://twitter.com/darashi/status/486031334591062018

  3. lࢲz

  4. CV[[UUFSDPN
 ˠݱߦͷόοΫΤϯυ͸΄΅(P (PSPPOHB ˠશจݕࡧΤϯδϯ(SPPOHBͷ(PόΠϯσΟϯά ࠷ۙͷ͓࢓ࣄ
 ˠؾ͕͍ͭͨΒେମ(P

  5. Code organization Workspaces The go tool is designed to work

    with open source code maintained in public repositories. Although you don't need to publish your code, the model for how the environment is set up works the same whether you do or not. Go code must be kept inside a workspace. A workspace is a directory hierarchy with three directories at its root: src contains Go source files organized into packages (one package per directory), pkg contains package objects, and bin contains executable commands. The go tool builds source packages and installs the resulting binaries to the pkg and bin directories. The src subdirectory typically contains multiple version control repositories (such as for Git or Mercurial) that track the development of one or more source packages. To give you an idea of how a workspace looks in practice, here's an example: bin/ hello # command executable outyet # command executable pkg/ linux_amd64/ github.com/golang/example/ stringutil.a # package object src/ github.com/golang/example/ .git/ # Git repository metadata hello/ hello.go # command source outyet/ main.go # command source main_test.go # test source stringutil/ reverse.go # package source reverse_test.go # test source https://golang.org/doc/code.html
  6. github.com/golang/example/ stringutil.a # package object src/ github.com/golang/example/ .git/ # Git

    repository metadata hello/ hello.go # command source outyet/ main.go # command source main_test.go # test source stringutil/ reverse.go # package source reverse_test.go # test source This workspace contains one repository (example) comprising two commands (hello and outyet) and one library (stringutil). A typical workspace would contain many source repositories containing many packages and commands. Most Go programmers keep all their Go source code and dependencies in a single workspace. Commands and libraries are built from different kinds of source packages. We will discuss the distinction later. The GOPATH environment variable The GOPATH environment variable specifies the location of your workspace. It is likely the only environment variable you'll need to set when developing Go code. To get started, create a workspace directory and set GOPATH accordingly. Your workspace can be located wherever you like, but we'll use $HOME/go in this document. Note that this must not be the same path as your Go installation. $ mkdir $HOME/go $ export GOPATH=$HOME/go For convenience, add the workspace's bin subdirectory to your PATH: $ export PATH=$PATH:$GOPATH/bin Package paths https://golang.org/doc/code.html
  7. Code organization Workspaces The go tool is designed to work

    with open source code maintained in public repositories. Although you don't need to publish your code, the model for how the environment is set up works the same whether you do or not. Go code must be kept inside a workspace. A workspace is a directory hierarchy with three directories at its root: src contains Go source files organized into packages (one package per directory), pkg contains package objects, and bin contains executable commands. The go tool builds source packages and installs the resulting binaries to the pkg and bin directories. The src subdirectory typically contains multiple version control repositories (such as for Git or Mercurial) that track the development of one or more source packages. To give you an idea of how a workspace looks in practice, here's an example: bin/ hello # command executable outyet # command executable pkg/ linux_amd64/ github.com/golang/example/ stringutil.a # package object src/ github.com/golang/example/ .git/ # Git repository metadata hello/ hello.go # command source outyet/ main.go # command source main_test.go # test source stringutil/ reverse.go # package source reverse_test.go # test source ͕͜͜(01"5) https://golang.org/doc/code.html
  8. Έͳ͞Μ͸HJUDMPOFͨ͠
 σΟϨΫτϦΛ
 Ͳ͜ʹஔ͍͍ͯ·͔͢

  9. ྫ  ͓࢓ࣄ͸dXPSL ͦΕҎ֎͸dHJU

  10. ͱ͸͍͑ʜ

  11. dHJUʹஔ͘Α͏ͳ
 ϓϩδΣΫτΛ
 ͓࢓ࣄͰ৮Δ͜ͱ΋͋Δ

  12. lXPSLͱ͸Կ͔z

  13. ৺ͷ໎͍͸
 σΟϨΫτϦͷ໎͍

  14. ͋ͷϚγϯͱ͜ͷϚγϯͰ
 ಉ͡ϓϩδΣΫτ͕
 ඍົʹҧ͏഑ஔʹ

  15. ΍΍͍͜͠

  16. ͦ͜Ͱʜ

  17. ࠷ۙ)0.&Λ
 (01"5)ʹͯ͠Έͨͱ͜Ζ
 ҙ֎ͱ͍͍ײ͡

  18. FYQPSU(01"5))0.&

  19. HJUIVCDPNEBSBTIJHPSPPOHB ˠdTSDHJUIVCDPNEBSBTIJHPSPPOHB

  20. HJUFYNQMFDPNIJNJUTVBXFTPNFXPSL ˠdTSDHJUFYBNQMFDPNIJNJUTVBXFTPNFXPSL

  21. (PҎ֎ͷϓϩδΣΫτ΋
 શͯ͜ͷϧʔϧͰ഑ஔ͢Δ

  22. ༧૝͞ΕΔ൓Ԡ

  23. lͳʹͦΕΩϞ͍z

  24. 5IFNBTDPUXBTEFTJHOFECZ3FOÉF'SFODI
 -JDFOTFEVOEFS$$#:

  25. l͙ͪΌ͙ͪΌʹͳΔͷͰ͸z

  26. 5IFNBTDPUXBTEFTJHOFECZ3FOÉF'SFODI
 -JDFOTFEVOEFS$$#:

  27. l(PʹೖΓͯ͸(Pʹै͑z —Yoji Shidara, 7 Jul 2014. https://twitter.com/darashi/status/486031334591062018

  28. ࣮͸(PΛॻ͔ͳ͍ਓʹ΋
 Φεεϝ

  29. ΂ΜΓ

  30. ͜Ε͸XPSL͔ MJGF͔ʁ XPSLͱ͸Կ͔  ͱ͔ߟ͑ͳ͍͍ͯ͘

  31. ಉ͡ϓϩδΣΫτ͸
 ͲͷϚγϯͰ΋
 উखʹಉ͡৔ॴʹஔ͔ΕΔ

  32. ୳͢ͱ͖΋͙͢ʹݟ͔ͭΔ

  33. ࣮͸(JUαʔό໊΍
 (JU)VCͷ0SHBOJ[BUJPO
 ͕ҧ͏͜ͱʹΑͬͯ
 ͦͦ͜͜ϚτϞʹ෼ྨ͞ΕΔ

  34. ʮ΅͘ͷߟ͑ͨ࠷ڧͷ෼ྨʯ ΑΓ͸Πέͯͳ͍͔΋
 ʜͰ΋ߟ͑Δඞཁ͕ͳ͘ͳΔ ු͍ͨ෼Ͱ΋ͬͱผͷ͜ͱΛߟ͑Α͏

  35. (Pͱ஥ྑ͠

  36. ͍·͍ͪͳͱ͜Ζ

  37. ϓϩδΣΫτ։࢝͢Δͱ͖
 Ͳ͜ʹஔ͔͘໰୊ ˠdTSDHJUIVCDPNEBSBTIJ<OFXQSPKFDU>ʹ
 ஔ͘Α͏ʹ͍ͯ͠Δ يಓʹ৐ͬͨΒ݁ہ(JU)VCʹஔ͘

  38. ϓϩδΣΫτ͕Ҡಈͨ͠Β
 ໘౗ ˠେৎ෉ɺͦΜͳʹසൟʹ͸Ҡಈ͠ͳ͍

  39. ศར৘ใ

  40. Ҡߦ

  41. ݕࡧΩʔϫʔυ  ݕࡧ  2015-01  Go  τοϓ 

    mલͷ೔ه  ݄   ࠷৽  ࣍ͷ೔ه  ਫ  {  ฤू  )TCU%JBSZ  Ր  <௕೥೔ه> ˙XPSLJOHTQBDFΛHP४ڌʹͨ͠ ৄࡉ͸HIRΛ࢖ͬͨϩʔΧϧϦϙδτϦͷ౷Ұతɾޮ཰తͳ؅ཧʹ͍ͭͯEFMJSJPVTUIPVHIUTΛಡΜͰ͍ͩ͘͞ɻৄ͍͠಺༰ ͸શ෦ॻ͍ͯ·͢ɻ ΜͰ΋ͬͯɺݱঢ়͔ΒͲ͏Ҡߦ͢Ε͹͍͍ͷ͔ͱ͍͏࿩Ͱ͕͢ɺࠓ·ͰDQBO HFNT SBJMTΈ͍ͨʹԿͱͳ͘෼ྨ͍ͯͨ͠σΟϨ ΫτϦΛશ෦·ΔͬͱHP४ڌͷߏ଄ʹҠߦ͢ΔεΫϦϓτΛͰͬͪ͋͛·ͨ͠ IUUQTHJUIVCDPNITCUTDSJQUTCMPCNBTUFSHJUHPSC ࣗ෼͸d%PDVNFOUTΛdTSDͷΑ͏ʹ࢖͍ͬͯΔͷͰUBSHFUEJS͸d%PDVNFOUTʹͳͬͯ·͕͢ɺద౰ʹม͑ͯ࢖ͬͯͩ͘͞ ͍ɻ 2 1 ͍͍Ͷʂ ͍͍Ͷʂ <ποίϛΛೖΕΔ> ποίϛɾίϝϯτ͕͋Ε͹Ͳ͏ͧTQBNରࡦͰ&NBJMཝ͸Ӆͯ͋͠Γ·͢ɻ΋͠&NBJMཝ͕ݟ͍͑ͯͯ΋ɺԿ΋ೖྗ͠ͳ͍ͰԼ͍͞ɻ·ͨɺ63*͸ͭ· ͰೖྗՄೳͰ͢ɻ ໊͓લ ίϝϯτ ౤ߘ http://www.hsbt.org/diary/20140603.html
  42. HIR

  43. Explore Features Enterprise Blog HTTPS clone URL You can clone

    with HTTPS or Subversion. ghq / ! latest&commit&b6f7aadbeb Remote repository management made easy update doc motemen authored on Dec 9, 2014 " utils modify "svn" category log color as git, hg 3 months ago " zsh fixup docs and zsh completion 3 months ago # .gitignore initial version 9 months ago # .travis.yml make test 8 months ago # CHANGELOG.md Version 0.4: Introduced per-URL configuration 7 months ago # LICENSE MIT license 7 months ago # Makefile implemented ghq import < FILE 5 months ago $ README.asciidoc doc 9 months ago # commands.go modify clone error message 3 months ago # commands_test.go `ghq get -shallow` to perform `git clone --depth 1` 7 months ago # ghq.txt update doc a month ago # git.go Git version testing 7 months ago # git_test.go Git version testing 7 months ago % Sign up Sign up Sign in Sign in Search 361 33 ⋆ ⋆ Star Star ' ' Fork Fork motemen / ghq ( ) Code * Issues 3 + Pull Requests 5 , Pulse - Graphs https://github.com/motemen/ghq. ! ! ? . . Clone in Desktop Clone in Desktop / / Download ZIP Download ZIP 182 commits 7 branches 12 releases 21 contributors 6 2 7 5 0 0 1 1 2 2 master master branch: + This repository https://github.com/motemen/ghq
  44. QFDP

  45. Explore Features Enterprise Blog HTTPS clone URL You can clone

    with HTTPS or Subversion. peco / ! latest&commit&892f828463 Simplistic interactive filtering tool Merge pull request #219 from jedipunkz/master lestrrat authored 11 days ago " build Fix build script a month ago " cmd/peco version++; this is v0.2.11 a month ago " keyseq exec gofmt 5 months ago # .gitignore slight addition to .gitignore 2 months ago # .travis.yml remove 1.1 a month ago # Changes version++; this is v0.2.11 a month ago # LICENSE Initial commit 8 months ago # README.md fixed typos 2 months ago # action.go fixed a reverse order problem of SelectNext and SelectPrevious key. 11 days ago # action_test.go Fix a bunch of race conditions 3 months ago # config.go Start adding test for layout 5 months ago # config_darwin.go golint 6 months ago # config_posix.go golint 6 months ago $ Sign up Sign up Sign in Sign in Search 1,997 69 ⋆ ⋆ Star Star & & Fork Fork peco / peco ' ( Code ) Issues 3 * Pull Requests 0 + Wiki , Pulse - Graphs https://github.com/peco/peco.gi ! ! ? . . Clone in Desktop Clone in Desktop / / Download ZIP Download ZIP 694 commits 5 branches 25 releases 24 contributors 4 2 5 6 0 0 1 1 2 2 master master branch: + … This repository https://github.com/peco/peco
  46. HIR QFDP

  47. function peco-src () { local selected_dir=$(ghq list --full-path | peco

    --query "$LBUFFER") if [ -n "$selected_dir" ]; then BUFFER="cd ${selected_dir}" zle accept-line fi zle clear-screen } zle -N peco-src [TISD
  48. (PΛ৮͍ͬͯΔͱײ͡Δ͜ͱ

  49. Ұݟ͢Δͱҧ࿨ײ͕͋Δ͚ΕͲ
 ࣮ࡍʹ΍ͬͯΈΔͱ
 ͳΔ΄Ͳײ͕ੜ͡Δ

  50. l(PʹೖΓͯ͸(Pʹै͑z —Yoji Shidara, 7 Jul 2014. https://twitter.com/darashi/status/486031334591062018

  51. )0.&ͱ(01"5)ͱࢲ
 —HOME, GOPATH and me ઃᒜ༸࣐
 !EBSBTIJ Sapporo #golang Meetup


    2015-01-21 5IFNBTDPUXBTEFTJHOFECZ3FOÉF'SFODI
 -JDFOTFEVOEFS$$#: