Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Cyclic structure support #4

@ferhatelmas

Description

@ferhatelmas
package main

import (
    "fmt"

    "github.com/mitchellh/hashstructure"
)

func hash(i interface{}) {
    hash, err := hashstructure.Hash(i, nil)
    if err != nil {
        panic(err)
    }

    fmt.Printf("%v: %d\n", i, hash)
}

func main() {
    m := map[string]interface{}{}
    m["1"] = "1"
    // prints 0
    hash(m)
    m["2"] = "2"
    // prints 0
    hash(m)
    m["3"] = 3
    // does not print 0
    hash(m)
    m["m"] = m
    // fatal error: stack overflow
    hash(m)
}

Cyclic structures aren't supported. Is it expected and/or any plan to add support ?

Also note that in the first two cases, hash is same even if map is updated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions