Skip to content

修复切片数据索引位置交换导致的bug #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

robbinhan
Copy link

[]string{"web.business.image/202009165d0d6aeb03ec6ecb494897d8", "web.business.image/202009045d0d1788b05942ca42988dca"}

[]string{"web.business.image/202009045d0d1788b05942ca42988dca", "web.business.image/202009165d0d6aeb03ec6ecb494897d8"}

fix index exchange diff error

no index will output type :

from :web.business.image/202009165d0d6aeb03ec6ecb494897d8,to:<nil>,path: []string{"xxx", "xxx", "1"},type:delete
from :<nil>,to:web.business.image/202009045d0d25b79ba5011f438dafb7,path: []string{"xxx", "xxx", "0"},type:create

@purehyperbole
Copy link
Member

Hi @robbinhan , thanks for submitting this contribution!

Tests are failing for your PR as this changes the behaviour of diffing slices for all use cases.

I'm not sure if that change is actually necessary, as there is already diff.SliceOrdering(), which should produce more or less the same result?

func main() {
	a := []string{"web.business.image/202009165d0d6aeb03ec6ecb494897d8", "web.business.image/202009045d0d1788b05942ca42988dca"}
	
	b := []string{"web.business.image/202009045d0d1788b05942ca42988dca", "web.business.image/202009165d0d6aeb03ec6ecb494897d8"}

	cl, _ := diff.Diff(a, b)
	
	// produces '[]'
	fmt.Println(cl)

	cl, _ = diff.Diff(a, b, diff.SliceOrdering(true))
	
	// produces: '[{update [0] web.business.image/202009165d0d6aeb03ec6ecb494897d8 web.business.image/202009045d0d1788b05942ca42988dca <nil>} {update [1] web.business.image/202009045d0d1788b05942ca42988dca web.business.image/202009165d0d6aeb03ec6ecb494897d8 <nil>}]'
	fmt.Println(cl)
}

@robbinhan
Copy link
Author

ok,I will try again

@robbinhan robbinhan closed this Nov 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants