Giter Club home page Giter Club logo

Comments (6)

kaihendry avatar kaihendry commented on June 24, 2024

This API is very weird: https://godoc.org/github.com/aws/aws-sdk-go-v2/aws/endpoints#Partition.Regions

A map[string]Region for a return?! A list is far more idiomatic, no?

Also the second bool parameter in the return of https://godoc.org/github.com/aws/aws-sdk-go-v2/aws/endpoints#Partitions.ForPartition is really not idiomatic.

from aws-sdk-go-v2.

xibz avatar xibz commented on June 24, 2024

@kaihendry - Second bool parameter being returned can be found in the standard library. See here. I believe this best indicates whether or not something has been found.

In addition, what data structure that is returned such as map versus [] doesn't really fit the definition of idiomatic. The map was chosen to let users easily grab the region they wanted without needing to iterate. We could type alias it like shown here in the standard library. How do you feel about it being type aliased instead of a map?

from aws-sdk-go-v2.

kaihendry avatar kaihendry commented on June 24, 2024

Thanks for the link. TIL something new. Though I understand an ENV VAR="" being set as empty. However why would a partition be and why would you need to account for that?

I don't quite understand what you mean by aliased. You referenced map[string][]string ?

from aws-sdk-go-v2.

xibz avatar xibz commented on June 24, 2024

@kaihendry - I referenced the http.Header header object that type aliases it to a map[string][]string.

from aws-sdk-go-v2.

jasdel avatar jasdel commented on June 24, 2024

@kaihendry Thanks for the feedback. The endpoints#Partition.Regions returns a map to make it easy to determine if a partition includes a region. A partition is an idea like AWS global, AWS China, and AWS GovCloud. Each of these partitions have their own unique set of regions.

The reason Region returns a map instead a slice isn't very strong. But it was consistent with the method for services, which are also a map. In addition this is partly because the data is stored internally as maps. Converting the internal map to a list would add overhead for each method.

endpoints#Partitions could be updated to include a ForService to return a sub slice of partitions which include support for a service.

For your original linked code example. I'd suggest the following pattern to simplify iterating over the regions, https://play.golang.org/p/6M6Cd9dusm3

from aws-sdk-go-v2.

github-actions avatar github-actions commented on June 24, 2024

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

from aws-sdk-go-v2.

Related Issues (20)

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.