Giter Site home page Giter Site logo

Comments (1)

EddieIvan01 avatar EddieIvan01 commented on July 22, 2024

感谢您的支持

Python里允许这样写是因为dict的构造函数允许传递二元元组类型

>>> dict([('a', 1), ('b', 2)])
{'a': 1, 'b': 2}

但在Go这种静态类型语言里map的键值和数组的成员需要严格指定类型的,所以不可能和一个动态类型语言的API完全一样(而且这属于语言基础类型的设计,在库函数的层面修改会造成不必要的开销,比如Data成员允许传入interface{}然后作类型断言)

如果确实需要这样的功能,建议手动迭代切片转化为map类型

from nic.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.