我正在尝试将一个常量从C移动到位于头文件中的Ada.
file.h
#define TEST 0x1234
Run Code Online (Sandbox Code Playgroud)
我如何将此常量导出到ada?我知道导出函数并将它们导入ada但我似乎无法弄清楚如何对常量做同样的事情.
说我有一个像这样的http处理程序:
func ReallyLongFunction(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello World!")
// run code that takes a long time here
// Executing dd command with cmd.Exec..., etc.
})
Run Code Online (Sandbox Code Playgroud)
如果用户在不运行后续代码的情况下刷新页面或以其他方式取消请求,是否可以中断此功能,我该怎么办?
我尝试这样做:
notify := r.Context().Done()
go func() {
<-notify
println("Client closed the connection")
s.downloadCleanup()
return
}()
Run Code Online (Sandbox Code Playgroud)
但是无论何时我打断之后的代码仍然可以运行。