小编Kro*_*oid的帖子

我可以在docker容器中获取ip地址吗?

如何在这个容器中获取容器ip地址?

'docker inspect $ hostname ...'不合适,因为我没有将/var/run/docker.sock主机文件共享到容器中.

ip-address docker

39
推荐指数
3
解决办法
3万
查看次数

Golang XML解析

我的XML数据:

<dictionary version="0.8" revision="403605">
    <grammemes>
        <grammeme parent="">POST</grammeme>
        <grammeme parent="POST">NOUN</grammeme>
    </grammemes>
</dictionary>
Run Code Online (Sandbox Code Playgroud)

我的代码:

type Dictionary struct {
    XMLName xml.Name `xml:"dictionary"`
    Grammemes *Grammemes `xml:"grammemes"`
}

type Grammemes struct {
    Grammemes []*Grammeme `xml:"grammeme"`
}

type Grammeme struct {
    Name string `xml:"grammeme"`
    Parent string `xml:"parent,attr"`
}
Run Code Online (Sandbox Code Playgroud)

我得到Grammeme.Parent属性,但我没有得到Grammeme.Name.为什么?

xml go

8
推荐指数
1
解决办法
1万
查看次数

如何在松露中测试应付方法?

我正在尝试在松露框架中测试智能合约的应付方法:

contract Contract {
  mapping (address => uint) public balances;

  function myBalance() public view returns(uint) {
    return balances[msg.sender];
  }

  function deposit() external payable {
    balances[msg.sender] += msg.value;
  }
}

contract TestContract {

  function testDeposit() external payable {
    Contract c = new Contract();

    c.deposit.value(1);

    Assert.equal(c.myBalance(), 1, "#myBalance() should returns 1");
  }
}
Run Code Online (Sandbox Code Playgroud)

我运行后truffle test,它失败并TestEvent(result: <indexed>, message: #myBalance() should returns 1 (Tested: 0, Against: 1))出现错误。为什么?

testing ethereum solidity smartcontracts truffle

3
推荐指数
1
解决办法
1425
查看次数

标签 统计

docker ×1

ethereum ×1

go ×1

ip-address ×1

smartcontracts ×1

solidity ×1

testing ×1

truffle ×1

xml ×1