donglv6960 2017-06-22 01:32
浏览 4
已采纳

将“生成”更改为运行脚本的目录吗?

I'm trying to generate some code by several tools. So, I've write a file data.go as

package main           

//go:generate awk -v OFILE=names.go -f gen_table.awk $HOME/prj/header.h     
//go:generate gofmt -w names.go             
//go:generate ./gen_index_html.sh              

The generated names.go won't formatted automatically, so, I added the second line to force the correct format. And I assume it runs subsequently. Will Go generate jump into this directory before run these command? Because the script gen_index_html.sh just accept work in current directory.

  • 写回答

1条回答 默认 最新

  • dongzaocheng3214 2017-06-22 05:28
    关注

    Per the documentation:

    The generator is run in the package's source directory.

    So, whatever command is run with generate will be run in the same directory as the file containing the generate directive.

    Multiple generate directives in one file are executed one at a time in source code order.

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

报告相同问题?

悬赏问题

  • ¥15 关于#c##的问题:treenode反序列化后获取不到上一节点和下一节点,Fullpath和Handle报错
  • ¥15 一部手机能否同时用不同的app进入不同的直播间?
  • ¥15 没输出运行不了什么问题
  • ¥20 输入import torch显示Intel MKL FATAL ERROR,系统驱动1%,: Cannot load mkl_intel_thread.dll.
  • ¥15 点云密度大则包围盒小
  • ¥15 nginx使用nfs进行服务器的数据共享
  • ¥15 C#i编程中so-ir-192编码的字符集转码UTF8问题
  • ¥15 51嵌入式入门按键小项目
  • ¥30 海外项目,如何降低Google Map接口费用?
  • ¥15 fluentmeshing