小编kir*_*irk的帖子

GNAT 社区版中没有 GNATtest?

当我尝试在 GNAT 2020 社区版(Windows 10 64 位)中生成单元测试时,出现缺少 gnattest 工具的错误:could not locate gnattest. 同样发生在 Ubuntu 20.04(在 WSL 中)和包 gnat-10: could not locate x86_64-linux-gnu-gnattest-10

GNATtest 不是 GNAT 2020 社区版的一部分,如 AdaCores 网站 ( https://www.adacore.com/gnatpro/comparison ) 上所示?

ada gnat

2
推荐指数
1
解决办法
350
查看次数

Golang:附加切片或没有分配

append()当给定切片的容量不足时,Go的功能仅分配新的切片数据(另请参阅:https://stackoverflow.com/a/28143457/802833).这可能导致意外行为(至少对我来说是一个golang新手):

package main

import (
    "fmt"
)

func main() {

    a1 := make([][]int, 3)
    a2 := make([][]int, 3)
    b := [][]int{{1, 1, 1}, {2, 2, 2}, {3, 3, 3}}
    common1 := make([]int, 0)
    common2 := make([]int, 0, 12) // provide sufficient capacity
    common1 = append(common1, []int{10, 20}...)
    common2 = append(common2, []int{10, 20}...)

    idx := 0
    for _, k := range b {
        a1[idx] = append(common1, k...) // new slice is allocated
        a2[idx] = append(common2, k...) …
Run Code Online (Sandbox Code Playgroud)

append go slice

-4
推荐指数
1
解决办法
1983
查看次数

标签 统计

ada ×1

append ×1

gnat ×1

go ×1

slice ×1