Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
golang类型转换循环-apache模块_Apache_Go_Apache Modules_Cgo - Fatal编程技术网

golang类型转换循环-apache模块

golang类型转换循环-apache模块,apache,go,apache-modules,cgo,Apache,Go,Apache Modules,Cgo,我正在尝试构造一个Apache模块系统的Go接口。也就是说,我希望能够从Apache模块调用Go函数。这是我的Go文件: package main // #cgo CFLAGS: -I/usr/include/apache2 -I/usr/include/apr-1.0 // #include <httpd.h> import "C" //export handler func handler(r *C.request_rec) int { ap_set_content_

我正在尝试构造一个Apache模块系统的Go接口。也就是说,我希望能够从Apache模块调用Go函数。这是我的Go文件:

package main

// #cgo CFLAGS: -I/usr/include/apache2 -I/usr/include/apr-1.0
// #include <httpd.h>
import "C"

//export handler
func handler(r *C.request_rec) int {
    ap_set_content_type(r, "text/html");
    ap_rprintf(r, "Hello, world from Go")
    return OK;
}
第8行是函数“handler”开始的那一行。有什么建议吗

或者,当我使用cgo(
go工具cgo mod_frugal.go
)构建时,它根本看不到我的include指令:

/home/vagrant/mod_frugal/src/mod_frugal.go:4:20: fatal error: httpd.h: No such file or directory
// #include <httpd.h>
                ^
compilation terminated.
也许我需要链接到libhttpd?我只是在互联网上找不到任何关于针对apache2的链接,比如libhttpd

编辑:

请随意跟随对话:

/home/vagrant/mod_frugal/src/mod_frugal.go:4:20: fatal error: httpd.h: No such file or directory
// #include <httpd.h>
                ^
compilation terminated.
package main

// #cgo CFLAGS: -I/usr/include/apache2 -I/usr/include/apr-1.0
// #include "mod_frugal.h"
import "C"

//export handler
func handler(r *C.struct_request_rec) int {
    C.ap_set_content_type(r, "text/html")
    C.ap_rprintf(r, "<h1>Hello, world from Go!</h1>")
    return OK
}
# _/home/vagrant/mod_frugal/src
37: error: 'ap_set_content_type' undeclared (first use in this function)
37: error: 'ap_rprintf' undeclared (first use in this function)