Skip to content

Changes in behavior of go fmt in 1.11 #1465

Closed

Description

@elfosardo

Submitting a PR (#1461) we encountered an awkward issue when running the format script.
When running it with go1.11 everything looks good, on the other hand, running it with go1.10 will fail the test.

This is due to a documented change of behavior in go fmt between 1.10 and 1.11.
golang/go#26228

Ideally the project should use only one version (the latest) of go to run the format script.

Activity

  1. jtopjian commented on Feb 22, 2019

    @jtopjian
    Contributor

    @elfosardo rewriting the problematic structs to use newlines (which is the more common style anyway) should resolve this problem:

    diff --git a/openstack/baremetal/v1/drivers/testing/fixtures.go b/openstack/baremetal/v1/drivers/testing/fixtures.go
    index be080a9..01c55aa 100644
    --- a/openstack/baremetal/v1/drivers/testing/fixtures.go
    +++ b/openstack/baremetal/v1/drivers/testing/fixtures.go
    @@ -218,19 +218,54 @@ const SingleDriverDiskProperties = `
    
     var (
            DriverAgentIpmitool = drivers.Driver{
    -               Name:       "agent_ipmitool",
    -               Type:       "classic",
    -               Hosts:      []string{"897ab1dad809"},
    -               Links:      []interface{}{map[string]interface{}{"href": "http://127.0.0.1:6385/v1/drivers/agent_ipmitool", "rel": "self"}, map[string]interface{}{"href": "http://127.0.0.1:6385/drivers/agent_ipmitool", "rel": "bookmark"}},
    -               Properties: []interface{}{map[string]interface{}{"href": "http://127.0.0.1:6385/v1/drivers/agent_ipmitool/properties", "rel": "self"}, map[string]interface{}{"href": "http://127.0.0.1:6385/drivers/agent_ipmitool/properties", "rel": "bookmark"}},
    +               Name:  "agent_ipmitool",
    +               Type:  "classic",
    +               Hosts: []string{"897ab1dad809"},
    +               Links: []interface{}{
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/v1/drivers/agent_ipmitool",
    +                               "rel":  "self",
    +                       },
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/drivers/agent_ipmitool",
    +                               "rel":  "bookmark",
    +                       },
    +               },
    +               Properties: []interface{}{
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/v1/drivers/agent_ipmitool/properties",
    +                               "rel":  "self",
    +                       },
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/drivers/agent_ipmitool/properties",
    +                               "rel":  "bookmark",
    +                       },
    +               },
            }
    
            DriverFake = drivers.Driver{
    -               Name:       "fake",
    -               Type:       "classic",
    -               Hosts:      []string{"897ab1dad809"},
    -               Links:      []interface{}{map[string]interface{}{"href": "http://127.0.0.1:6385/v1/drivers/fake", "rel": "self"}, map[string]interface{}{"href": "http://127.0.0.1:6385/drivers/fake", "rel": "bookmark"}},
    -               Properties: []interface{}{map[string]interface{}{"href": "http://127.0.0.1:6385/v1/drivers/fake/properties", "rel": "self"}, map[string]interface{}{"href": "http://127.0.0.1:6385/drivers/fake/properties", "rel": "bookmark"}},
    +               Name:  "fake",
    +               Type:  "classic",
    +               Hosts: []string{"897ab1dad809"},
    +               Links: []interface{}{
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/v1/drivers/fake",
    +                               "rel":  "self",
    +                       },
    +                       map[string]interface{}{"href": "http://127.0.0.1:6385/drivers/fake",
    +                               "rel": "bookmark",
    +                       },
    +               },
    +               Properties: []interface{}{
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/v1/drivers/fake/properties",
    +                               "rel":  "self",
    +                       },
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/drivers/fake/properties",
    +                               "rel":  "bookmark",
    +                       },
    +               },
            }
    
            DriverIpmi = drivers.Driver{
    @@ -259,8 +294,24 @@ var (
                    EnabledRaidInterfaces:       []string{"no-raid", "agent"},
                    EnabledStorageInterfaces:    []string{"noop"},
                    EnabledVendorInterfaces:     []string{"no-vendor"},
    -               Links:                       []interface{}{map[string]interface{}{"href": "http://127.0.0.1:6385/v1/drivers/ipmi", "rel": "self"}, map[string]interface{}{"href": "http://127.0.0.1:6385/drivers/ipmi", "rel": "bookmark"}},
    -               Properties:                  []interface{}{map[string]interface{}{"href": "http://127.0.0.1:6385/v1/drivers/ipmi/properties", "rel": "self"}, map[string]interface{}{"href": "http://127.0.0.1:6385/drivers/ipmi/properties", "rel": "bookmark"}},
    +               Links: []interface{}{
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/v1/drivers/ipmi", "rel": "self",
    +                       },
    +                       map[string]interface{}{"href": "http://127.0.0.1:6385/drivers/ipmi",
    +                               "rel": "bookmark",
    +                       },
    +               },
    +               Properties: []interface{}{
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/v1/drivers/ipmi/properties",
    +                               "rel":  "self",
    +                       },
    +                       map[string]interface{}{
    +                               "href": "http://127.0.0.1:6385/drivers/ipmi/properties",
    +                               "rel":  "bookmark",
    +                       },
    +               },
            }
    
            DriverIpmiToolProperties = drivers.DriverProperties{
  2. elfosardo commented on Feb 24, 2019

    @elfosardo
    ContributorAuthor

    @jtopjian thanks for the advice! I've pushed a new commit to the mentioned PR, hope Travis will like it :)

  3. elfosardo commented on Feb 26, 2019

    @elfosardo
    ContributorAuthor

    @jtopjian the workaround works fine, feel free to close this issue

  4. elfosardo commented on Feb 26, 2019

    @elfosardo
    ContributorAuthor

    didn't see I could close it :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions