douhui8025 2017-11-05 02:21
浏览 41
已采纳

如何从github构建Golang博客?

Im not very good with Go and I am having a lot of problems with understanding how common website features are made, so I thought it would be good to see a real example. I tried building https://github.com/golang/blog but its not working.

My gopath is apparently C:/Users/me/go as it should be.

*Edit Except if I run cd $GOPATH/src, it says C:\src doesnt exist, it looks in C: not C:/Users

Method 1. (running go get -u golang.org/x/blog) I open Powershell and run that in my Users/me/go/src directory and it says:

can't load package: package golang.org: no Go files in 
C:\Users\me\go\src\golang.org

But it does download the source files. So its basically this step? 'u can manually git clone the repository to $GOPATH/src/golang.org/x/blog.'

Then I dont know where to run go build or what to run. I tried go build -o blog.exe ./blog

and it says can't load package: package blog: cannot find package "blog" in any of: C:\Go\src\blog (from $GOROOT) C:\Users\me\go\src\blog (from $GOPATH)

I tried running the same command in different directories of the project and doesnt work.

  • 写回答

1条回答 默认 最新

  • dtmtu02882 2017-11-05 03:01
    关注

    I'll try to answer your questions. (Note that I am a Linux user, so there may be some discrepancies with the Windows commands below. You may want to follow these directions: http://www.wadewegner.com/2014/12/easy-go-programming-setup-for-windows/ to setup the GOROOT environment variable.)

    1. For method 1, the -u flag tells go to update the source code. Since you haven't downloaded it before, it lets you know with the error you see. What you want to run is go get golang.org/x/blog.

    2. To build the package, you first want to change the directory (cd) to the package root, so cd %GOPATH%\src\golang.org\x\blog or cd C:\Users\me\go\src\golang.org\x\blog. Next, you want to run go build. Then, you can run the output file, which should automatically be named blog.exe.

    Hopefully this helps! :)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用数码管显示学号(相关搜索:单片机)
  • ¥15 错误于library(org.Hs.eg.db): 不存在叫‘org.Hs.eg.db’这个名称的程序包,如何解决?
  • ¥60 求一个图片处理程序,要求将图像大小跟现实生活中的大小按比例联系起来的
  • ¥50 求一位精通京东相关开发的专家
  • ¥100 求懂行的大ge给小di解答下!
  • ¥15 pcl运行在qt msvc2019环境运行效率低于visual studio 2019
  • ¥15 MAUI,Zxing扫码,华为手机没反应。可提高悬赏
  • ¥15 python运行报错 ModuleNotFoundError: No module named 'torch'
  • ¥100 华为手机私有App后台保活
  • ¥15 sqlserver中加密的密码字段查询问题