我希望能够单步调试我正在制作的 Node.js 插件的 C++ 代码。我知道 CMake.js 有--debug
选项,但没有关于它的文档。
我正在 CLion 中使用 node-addon-api 模块。
我的 Azure Pipelines 构建在 CmdLine 阶段失败Error response from daemon: Container 6c04267ea73602db828802df820c5c33cf95223ad0dcd0e3ef73b545d51f3bfa is not running
。
我的azure-pipelines.yml
是:
pool:
vmImage: windows-2019
container: my-docker-container
steps:
- script: |
echo 'run build script'
Run Code Online (Sandbox Code Playgroud)
forDockerfile
是my-docker-container
:
FROM mcr.microsoft.com/windows/servercore:1809
# Do stuff
ENTRYPOINT ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
Run Code Online (Sandbox Code Playgroud)
我需要修复什么才能解决此错误?
我正在使用 .gitlab 测试 GitLab CI 管道gitlab-runner exec
。在执行脚本期间,Boost 遇到错误,并创建了一个日志文件。我想查看此日志文件,但我不知道如何查看。
.gitlab-ci.yml
在项目目录中:
image: alpine
variables:
GIT_SUBMODULE_STRATEGY: recursive
build:
script:
- apk add cmake
- cd include/boost
- sh bootstrap.sh
Run Code Online (Sandbox Code Playgroud)
我在我的机器上测试这个:
sudo gitlab-runner exec docker build --timeout 3600
Run Code Online (Sandbox Code Playgroud)
输出的最后几行:
Building Boost.Build engine with toolset ...
Failed to build Boost.Build build engine
Consult 'bootstrap.log' for more details
ERROR: Job failed: exit code 1
FATAL: exit code 1
Run Code Online (Sandbox Code Playgroud)
bootstrap.log
是我想看的。
追加- cat bootstrap.log
到.gitlab-ci.yml
不会输出文件内容,因为运行程序在此行之前退出。我尝试使用 来查看过去的容器sudo docker ps -a
,但这并没有显示 …
TS_NODE_PROJECT
当 ts-node 用于使用 Mocha 进行测试时,我在使用 env 变量时遇到问题。
项目结构如下所示:
src/
main_test.ts
tsconfig.json
package.json
Run Code Online (Sandbox Code Playgroud)
在我的测试中,我想使用异步函数,它需要"lib": ["es2018"]
作为编译选项。
// src/main_test.ts
describe('', () => {
it('test', () => {
(async function() {})()
});
});
// src/tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"lib": ["es2018"]
},
"exclude": [
"../node_modules"
]
}
Run Code Online (Sandbox Code Playgroud)
为了运行测试,我使用了这个命令,但它会导致一个错误:
TS_NODE_PROJECT='src' && mocha --require ts-node/register src/*_test.ts
# TSError: ? Unable to compile TypeScript:
# error TS2468: Cannot find global value 'Promise'.
# src/main_test.ts(3,10): error TS2705: An async function …
Run Code Online (Sandbox Code Playgroud) 我想Scan()
在 package 中使用sql
,但列数以及参数数将在运行时发生变化。这是签名Scan()
:
func (rs *Rows) Scan(dest ...interface{}) error
Run Code Online (Sandbox Code Playgroud)
根据文档,*interface{}
是Scan()
. 所以我想创建一个切片,[]*interface{}
并将其扩展为参数。
这就是我认为会起作用的:
func query(database *sql.DB) {
rows, _ := database.Query("select * from testTable")
for rows.Next() {
data := make([]*interface{}, 2)
err := rows.Scan(data...) // Compilation error
fmt.Printf("%v%v\n", *data[0], *data[1])
if err != nil {
fmt.Println(err.Error())
}
}
}
Run Code Online (Sandbox Code Playgroud)
编译失败,cannot use data (type []*interface {}) as type []interface {} in argument to rows.Scan
. 我认为这data...
会扩展到&data[0], …
我在从父进程发送信号并在子进程中接收信号时遇到问题。
这是子进程的代码。当它收到 SIGINT 时退出。
// child.go
func main() {
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt)
fmt.Println("started")
<-stop
fmt.Println("stopped")
}
Run Code Online (Sandbox Code Playgroud)
这是父进程。它启动child.go
,发送 SIGINT,然后等待它退出。
// main.go
func main() {
// Start child process
cmd := exec.Command("go", "run", "child.go")
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Start: " + err.Error())
return
}
// Wait, then send signal
time.Sleep(time.Millisecond * 500)
err = cmd.Process.Signal(os.Interrupt)
if err != nil {
_, _ …
Run Code Online (Sandbox Code Playgroud) 如何在 Windows 上使用 Visual Studio 编译和嵌入 v8?官方指南适用于 Linux,但不适用于使用 Visual Studio 的 Windows,因为我在尝试构建 v8 和示例项目时不断收到编译错误。
Azure Devops 中的“服务连接”这个东西非常令人困惑。我想创建一个服务连接,以便能够连接到 Azure 并执行诸如通过管道部署到我的应用服务之类的操作。
问题是,我的订阅未列在下拉菜单中,而且我收到了一些无用的错误,例如“无法获取 Json Web 令牌(JWT)”或“无法查询服务连接 API ... AuthorizationFailed”。为了创建服务连接,我需要采取哪些步骤?
我想在 TypeScript 中创建一个类数组。这在普通 JavaScript 中是可能的:
class A {
constructor() {console.log('constructor');}
a() {}
}
const array = [A];
new (array[0])(); // Prints 'constructor'
Run Code Online (Sandbox Code Playgroud)
我想使用接口使数组类型安全。这是我在 TypeScript 中实现这一点的尝试:
interface I {
a();
}
class A implements I {
constructor() {console.log('constructor')}
a() {}
}
const array: I[] = [A];
new (array[0])();
Run Code Online (Sandbox Code Playgroud)
当我编译这个时,我收到以下错误:
Error:(16, 21) TS2322: Type 'typeof A' is not assignable to type 'I'.
Property 'a' is missing in type 'typeof A'.
Run Code Online (Sandbox Code Playgroud)
因为此错误消息提到typeof A is not assignable to type 'I'
,所以数组似乎不能包含类,就像typeof
用于实例化对象一样。 …
我在将WebSocket服务器放入Docker容器时遇到麻烦。
这是服务器代码,它使用“ connected”写入新连接。
// server.go
func RootHandler(w http.ResponseWriter, r *http.Request) {
upgrader := websocket.Upgrader{ // (Uses gorilla/websocket)
ReadBufferSize: 4096,
WriteBufferSize: 4096,
}
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
panic(err)
}
if err = conn.WriteMessage(websocket.TextMessage, []byte("connected")); err != nil {
panic(err)
}
}
func main() {
fmt.Println("server is running")
// For graceful shutdown
stop := make(chan os.Signal, 1)
signal.Notify(stop, os.Interrupt)
server := http.Server{Addr: "localhost:8000"}
defer server.Close()
http.HandleFunc("/", RootHandler)
go func() {
err := server.ListenAndServe()
if err …
Run Code Online (Sandbox Code Playgroud)