Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Packer
Commits
b627c550
Commit
b627c550
authored
5 years ago
by
Megan Marsh
Browse files
Options
Download
Email Patches
Plain Diff
update vendor
parent
3c58b9c1
main
actions/fix-check-links
azr/mini-dag
azr_acc_test_install_n_run_single_plugins
azr_implicit_requried_plugin_2
azr_remove_amazon_builder
b-azure_arm-cert-timeout
backport/brk.feat/remove-website-code/horribly-finer-bison
backport/clarify-builders-page/promptly-fun-cheetah
backport/nywilken/update-plugins-link/steadily-ace-bear
backport/update-docs-hcp-packer-ga/deeply-capital-malamute
backport/update-docs-hcp-packer-ga/slowly-golden-narwhal
backport/update-docs-hcp-packer-ga/solely-renewing-chipmunk
brk.feat/mdx-v2
build-after-tests
bump_hcp_sdk_go
config_docs
crt-onboarding-test
d-powershell-generated-docs
dependabot/github_actions/slackapi/slack-github-action-1.19.0
example-test
extract_outscale
f-inspect-regression
fix_1000
fix_100000
hcp-packer-registry-pps
improved-error-handling-hcp-packer
linode-hcp-ready
nywilken/update-external-plugins
packer-plugin-dev-documentation-updates
poc/packer-init
pr/10199
release/1.7.x
release/1.8.x
stable-website
testing_hcp_rewrite_two
update-alert-banner
update-community-codeowners
update_sdk
use_progress_bar
validate_locals
vscode-customization
wilken/hcl2_upgrade-legacy-mode
wilken/implicitly-required-plugins-legacy-mode
wilken/packer-legacy-mode
wilken/packer-par-client
zs.draft-empty-page-check-script
1.5.0
v1.8.0
v1.7.10
v1.7.9
v1.7.8
v1.7.7
v1.7.6
v1.7.5
v1.7.4
v1.7.3
v1.7.2
v1.7.1
v1.7.0
v1.6.6
v1.6.5
v1.6.4
v1.6.3
v1.6.2
v1.6.1
v1.6.0
v1.5.6
v1.5.5
v1.5.4
v1.5.3
v1.5.2
v1.5.1
v1.5.0
v1.4.5
nightly
list
No related merge requests found
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
vendor/github.com/ugorji/go/codec/build.sh
+220
-0
vendor/github.com/ugorji/go/codec/build.sh
vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl
+27
-0
vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl
vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go
+14
-0
.../github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go
vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go
+14
-0
...r/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go
vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go
+15
-0
.../github.com/ugorji/go/codec/goversion_makemap_gte_go19.go
vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go
+12
-0
...r/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go
vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go
+8
-0
...rji/go/codec/goversion_unexportedembeddedptr_gte_go110.go
vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go
+8
-0
...orji/go/codec/goversion_unexportedembeddedptr_lt_go110.go
vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go
+17
-0
...thub.com/ugorji/go/codec/goversion_unsupported_lt_go14.go
vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go
+10
-0
...or/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go
vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go
+10
-0
...or/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go
vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go
+8
-0
...r/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go
vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go
+8
-0
...or/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go
vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
+154
-0
vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl
+94
-0
vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl
with
619 additions
and
0 deletions
+619
-0
vendor/github.com/ugorji/go/codec/build.sh
0 → 100644
+
220
-
0
View file @
b627c550
#!/bin/bash
# Run all the different permutations of all the tests and other things
# This helps ensure that nothing gets broken.
_tests
()
{
local
gover
=
$(
go version |
cut
-f
3
-d
' '
)
# note that codecgen requires fastpath, so you cannot do "codecgen notfastpath"
local
a
=(
""
"safe"
"notfastpath"
"notfastpath safe"
"codecgen"
"codecgen safe"
)
for
i
in
"
${
a
[@]
}
"
do
echo
">>>> TAGS:
$i
"
local
i2
=
${
i
:-
default
}
case
$gover
in
go1.[0-6]
*
)
go vet
-printfuncs
"errorf"
"
$@
"
&&
go
test
${
zargs
[*]
}
-vet
off
-tags
"
$i
"
"
$@
"
;;
*
)
go vet
-printfuncs
"errorf"
"
$@
"
&&
go
test
${
zargs
[*]
}
-vet
off
-tags
"alltests
$i
"
-run
"Suite"
-coverprofile
"
${
i2
// /-
}
.cov.out"
"
$@
"
;;
esac
if
[[
"
$?
"
!=
0
]]
;
then return
1
;
fi
done
echo
"++++++++ TEST SUITES ALL PASSED ++++++++"
}
# is a generation needed?
_ng
()
{
local
a
=
"
$1
"
if
[[
!
-e
"
$a
"
]]
;
then
echo
1
;
return
;
fi
for
i
in
`
ls
-1
*
.go.tmpl gen.go values_test.go
`
do
if
[[
"
$a
"
-ot
"
$i
"
]]
;
then
echo
1
;
return
;
fi
done
}
_prependbt
()
{
cat
>
${
2
}
<<
EOF
// +build generated
EOF
cat
${
1
}
>>
${
2
}
rm
-f
${
1
}
}
# _build generates fast-path.go and gen-helper.go.
_build
()
{
if
!
[[
"
${
zforce
}
"
||
$(
_ng
"fast-path.generated.go"
)
||
$(
_ng
"gen-helper.generated.go"
)
||
$(
_ng
"gen.generated.go"
)
]]
;
then return
0
;
fi
if
[
"
${
zbak
}
"
]
;
then
_zts
=
`
date
'+%m%d%Y_%H%M%S'
`
_gg
=
".generated.go"
[
-e
"gen-helper
${
_gg
}
"
]
&&
mv
gen-helper
${
_gg
}
gen-helper
${
_gg
}
__
${
_zts
}
.bak
[
-e
"fast-path
${
_gg
}
"
]
&&
mv
fast-path
${
_gg
}
fast-path
${
_gg
}
__
${
_zts
}
.bak
[
-e
"gen
${
_gg
}
"
]
&&
mv
gen
${
_gg
}
gen
${
_gg
}
__
${
_zts
}
.bak
fi
rm
-f
gen-helper.generated.go fast-path.generated.go gen.generated.go
\
*
safe.generated.go
*
_generated_test.go
*
.generated_ffjson_expose.go
cat
>
gen.generated.go
<<
EOF
// +build codecgen.exec
// Copyright (c) 2012-2015 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
package codec
// DO NOT EDIT. THIS FILE IS AUTO-GENERATED FROM gen-dec-(map|array).go.tmpl
const genDecMapTmpl =
\`
EOF
cat
>>
gen.generated.go < gen-dec-map.go.tmpl
cat
>>
gen.generated.go
<<
EOF
\`
const genDecListTmpl =
\`
EOF
cat
>>
gen.generated.go < gen-dec-array.go.tmpl
cat
>>
gen.generated.go
<<
EOF
\`
const genEncChanTmpl =
\`
EOF
cat
>>
gen.generated.go < gen-enc-chan.go.tmpl
cat
>>
gen.generated.go
<<
EOF
\`
EOF
cat
>
gen-from-tmpl.codec.generated.go
<<
EOF
package codec
import "io"
func GenInternalGoFile(r io.Reader, w io.Writer) error {
return genInternalGoFile(r, w)
}
EOF
cat
>
gen-from-tmpl.generated.go
<<
EOF
//+build ignore
package main
import "
${
zpkg
}
"
import "os"
func run(fnameIn, fnameOut string) {
println("____ " + fnameIn + " --> " + fnameOut + " ______")
fin, err := os.Open(fnameIn)
if err != nil { panic(err) }
defer fin.Close()
fout, err := os.Create(fnameOut)
if err != nil { panic(err) }
defer fout.Close()
err = codec.GenInternalGoFile(fin, fout)
if err != nil { panic(err) }
}
func main() {
run("fast-path.go.tmpl", "fast-path.generated.go")
run("gen-helper.go.tmpl", "gen-helper.generated.go")
run("mammoth-test.go.tmpl", "mammoth_generated_test.go")
run("mammoth2-test.go.tmpl", "mammoth2_generated_test.go")
}
EOF
# explicitly return 0 if this passes, else return 1
go run
-tags
"notfastpath safe codecgen.exec"
gen-from-tmpl.generated.go
&&
rm
-f
gen-from-tmpl.
*
generated.go
&&
return
0
return
1
}
_codegenerators
()
{
if
!
[[
$zforce
||
$(
_ng
"values_codecgen
${
zsfx
}
"
)
]]
;
then return
0
;
fi
# Note: ensure you run the codecgen for this codebase (using $zgobase/bin/codecgen)
local
c9
=
"codecgen-scratch.go"
true
&&
echo
"codecgen ... "
&&
$zgobase
/bin/codecgen
-rt
codecgen
-t
'codecgen generated'
-o
values_codecgen
${
zsfx
}
-d
19780
$zfin
$zfin2
&&
cp
mammoth2_generated_test.go
$c9
&&
$zgobase
/bin/codecgen
-t
'!notfastpath'
-o
mammoth2_codecgen
${
zsfx
}
-d
19781 mammoth2_generated_test.go
&&
rm
-f
$c9
&&
echo
"generators done!"
}
_prebuild
()
{
echo
"prebuild: zforce:
$zforce
, zexternal:
$zexternal
"
zmydir
=
`
pwd
`
zfin
=
"test_values.generated.go"
zfin2
=
"test_values_flex.generated.go"
zsfx
=
"_generated_test.go"
# zpkg="ugorji.net/codec"
zpkg
=
${
zmydir
##*/src/
}
zgobase
=
${
zmydir
%%/src/*
}
# rm -f *_generated_test.go
rm
-f
codecgen-
*
.go
&&
_build
&&
cp
$zmydir
/values_test.go
$zmydir
/
$zfin
&&
cp
$zmydir
/values_flex_test.go
$zmydir
/
$zfin2
&&
_codegenerators
&&
if
[[
"
$(
type
-t
_codegenerators_external
)
"
=
"function"
]]
;
then
_codegenerators_external
;
fi
&&
if
[[
$zforce
]]
;
then
go
install
${
zargs
[*]
}
.
;
fi
&&
echo
"prebuild done successfully"
rm
-f
$zmydir
/
$zfin
$zmydir
/
$zfin2
}
_make
()
{
zforce
=
1
zexternal
=
1
(
cd
codecgen
&&
go
install
${
zargs
[*]
}
.
)
&&
_prebuild
&&
go
install
${
zargs
[*]
}
.
unset
zforce zexternal
}
_clean
()
{
rm
-f
gen-from-tmpl.
*
generated.go
\
codecgen-
*
.go
\
test_values.generated.go test_values_flex.generated.go
}
_usage
()
{
cat
<<
EOF
primary usage:
$0
-[tmpfxnld] for [tests, make, prebuild (force) (external), inlining diagnostics, mid-stack inlining, race detector]
EOF
if
[[
"
$(
type
-t
_usage_run
)
"
=
"function"
]]
;
then
_usage_run
;
fi
}
_main
()
{
if
[[
-z
"
$1
"
]]
;
then
_usage
;
return
1
;
fi
local
x
unset
zforce zexternal
zargs
=()
while
getopts
":ctbqmnrgupfxlzd"
flag
do
case
"x
$flag
"
in
'xf'
)
zforce
=
1
;;
'xx'
)
zexternal
=
1
;;
'xl'
)
zargs+
=(
"-gcflags"
)
;
zargs+
=(
"-l=4"
)
;;
'xn'
)
zargs+
=(
"-gcflags"
)
;
zargs+
=(
"-m"
)
;;
'xd'
)
zargs+
=(
"-race"
)
;;
x
\?
)
_usage
;
return
1
;;
*
)
x
=
$flag
;;
esac
done
shift
$((
OPTIND-1
))
case
"x
$x
"
in
'xt'
)
_tests
"
$@
"
;;
'xq'
)
_benchquick
"
$@
"
;;
'xb'
)
_bench
"
$@
"
;;
'xm'
)
_make
"
$@
"
;;
'xr'
)
_release
"
$@
"
;;
'xg'
)
_go
;;
'xu'
)
_githubupdate
;;
'xp'
)
_prebuild
"
$@
"
;;
'xc'
)
_clean
"
$@
"
;;
'xz'
)
_analyze
"
$@
"
;;
esac
unset
zforce zexternal
}
[
"."
=
`
dirname
$0
`
]
&&
_main
"
$@
"
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/gen-enc-chan.go.tmpl
0 → 100644
+
27
-
0
View file @
b627c550
{{.Label}}:
switch timeout{{.Sfx}} := z.EncBasicHandle().ChanRecvTimeout; {
case timeout{{.Sfx}} == 0: // only consume available
for {
select {
case b{{.Sfx}} := <-{{.Chan}}:
{{ .Slice }} = append({{.Slice}}, b{{.Sfx}})
default:
break {{.Label}}
}
}
case timeout{{.Sfx}} > 0: // consume until timeout
tt{{.Sfx}} := time.NewTimer(timeout{{.Sfx}})
for {
select {
case b{{.Sfx}} := <-{{.Chan}}:
{{.Slice}} = append({{.Slice}}, b{{.Sfx}})
case <-tt{{.Sfx}}.C:
// close(tt.C)
break {{.Label}}
}
}
default: // consume until close
for b{{.Sfx}} := range {{.Chan}} {
{{.Slice}} = append({{.Slice}}, b{{.Sfx}})
}
}
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_arrayof_gte_go15.go
0 → 100644
+
14
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build go1.5
package
codec
import
"reflect"
const
reflectArrayOfSupported
=
true
func
reflectArrayOf
(
count
int
,
elem
reflect
.
Type
)
reflect
.
Type
{
return
reflect
.
ArrayOf
(
count
,
elem
)
}
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_arrayof_lt_go15.go
0 → 100644
+
14
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build !go1.5
package
codec
import
"reflect"
const
reflectArrayOfSupported
=
false
func
reflectArrayOf
(
count
int
,
elem
reflect
.
Type
)
reflect
.
Type
{
panic
(
"codec: reflect.ArrayOf unsupported in this go version"
)
}
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_makemap_gte_go19.go
0 → 100644
+
15
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build go1.9
package
codec
import
"reflect"
func
makeMapReflect
(
t
reflect
.
Type
,
size
int
)
reflect
.
Value
{
if
size
<
0
{
return
reflect
.
MakeMapWithSize
(
t
,
4
)
}
return
reflect
.
MakeMapWithSize
(
t
,
size
)
}
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_makemap_lt_go19.go
0 → 100644
+
12
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build !go1.9
package
codec
import
"reflect"
func
makeMapReflect
(
t
reflect
.
Type
,
size
int
)
reflect
.
Value
{
return
reflect
.
MakeMap
(
t
)
}
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_gte_go110.go
0 → 100644
+
8
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build go1.10
package
codec
const
allowSetUnexportedEmbeddedPtr
=
false
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_unexportedembeddedptr_lt_go110.go
0 → 100644
+
8
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build !go1.10
package
codec
const
allowSetUnexportedEmbeddedPtr
=
true
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_unsupported_lt_go14.go
0 → 100644
+
17
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build !go1.4
package
codec
// This codec package will only work for go1.4 and above.
// This is for the following reasons:
// - go 1.4 was released in 2014
// - go runtime is written fully in go
// - interface only holds pointers
// - reflect.Value is stabilized as 3 words
func
init
()
{
panic
(
"codec: go 1.3 and below are not supported"
)
}
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go15.go
0 → 100644
+
10
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build go1.5,!go1.6
package
codec
import
"os"
var
genCheckVendor
=
os
.
Getenv
(
"GO15VENDOREXPERIMENT"
)
==
"1"
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_vendor_eq_go16.go
0 → 100644
+
10
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build go1.6,!go1.7
package
codec
import
"os"
var
genCheckVendor
=
os
.
Getenv
(
"GO15VENDOREXPERIMENT"
)
!=
"0"
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_vendor_gte_go17.go
0 → 100644
+
8
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build go1.7
package
codec
const
genCheckVendor
=
true
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/goversion_vendor_lt_go15.go
0 → 100644
+
8
-
0
View file @
b627c550
// Copyright (c) 2012-2018 Ugorji Nwoke. All rights reserved.
// Use of this source code is governed by a MIT license found in the LICENSE file.
// +build !go1.5
package
codec
var
genCheckVendor
=
false
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/mammoth-test.go.tmpl
0 → 100644
+
154
-
0
View file @
b627c550
//
Copyright
(
c
)
2012
-
2015
Ugorji
Nwoke
.
All
rights
reserved
.
//
Use
of
this
source
code
is
governed
by
a
MIT
license
found
in
the
LICENSE
file
.
//
Code
generated
from
mammoth
-
test
.
go
.
tmpl
-
DO
NOT
EDIT
.
package
codec
import
"testing"
import
"fmt"
import
"reflect"
//
TestMammoth
has
all
the
different
paths
optimized
in
fast
-
path
//
It
has
all
the
primitives
,
slices
and
maps
.
//
//
For
each
of
those
types
,
it
has
a
pointer
and
a
non
-
pointer
field
.
func
init
()
{
_
=
fmt
.
Printf
}
//
so
we
can
include
fmt
as
needed
type
TestMammoth
struct
{
{{
range
.
Values
}}{{
if
.
Primitive
}}{{/*
*/}}{{
.
MethodNamePfx
"F"
true
}}
{{
.
Primitive
}}
{{
.
MethodNamePfx
"Fptr"
true
}}
*{{
.
Primitive
}}
{{
end
}}{{
end
}}
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
not
.
MapKey
}}{{/*
*/}}{{
.
MethodNamePfx
"F"
false
}}
[]{{
.
Elem
}}
{{
.
MethodNamePfx
"Fptr"
false
}}
*[]{{
.
Elem
}}
{{
end
}}{{
end
}}{{
end
}}
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
.
MapKey
}}{{/*
*/}}{{
.
MethodNamePfx
"F"
false
}}
map
[{{
.
MapKey
}}]{{
.
Elem
}}
{{
.
MethodNamePfx
"Fptr"
false
}}
*
map
[{{
.
MapKey
}}]{{
.
Elem
}}
{{
end
}}{{
end
}}{{
end
}}
}
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
not
.
MapKey
}}{{/*
*/}}
type
{{
.
MethodNamePfx
"typMbs"
false
}}
[]{{
.
Elem
}}
func
(
_
{{
.
MethodNamePfx
"typMbs"
false
}})
MapBySlice
()
{
}
{{
end
}}{{
end
}}{{
end
}}
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
.
MapKey
}}{{/*
*/}}
type
{{
.
MethodNamePfx
"typMap"
false
}}
map
[{{
.
MapKey
}}]{{
.
Elem
}}
{{
end
}}{{
end
}}{{
end
}}
func
doTestMammothSlices
(
t
*
testing
.
T
,
h
Handle
)
{
{{
range
$
i
,
$
e
:=
.
Values
}}{{
if
not
.
Primitive
}}{{
if
not
.
MapKey
}}{{/*
*/}}
var
v
{{$
i
}}
va
[
8
]{{
.
Elem
}}
for
_
,
v
:=
range
[][]{{
.
Elem
}}{
nil
,
{},
{
{{
nonzerocmd
.
Elem
}},
{{
zerocmd
.
Elem
}},
{{
zerocmd
.
Elem
}},
{{
nonzerocmd
.
Elem
}}
}
}
{
{{/*
//
fmt
.
Printf
(
">>>> running mammoth slice v{{$i}}: %v
\n
"
,
v
)
//
-
encode
value
to
some
[]
byte
//
-
decode
into
a
length
-
wise
-
equal
[]
byte
//
-
check
if
equal
to
initial
slice
//
-
encode
ptr
to
the
value
//
-
check
if
encode
bytes
are
same
//
-
decode
into
ptrs
to
:
nil
,
then
1
-
elem
slice
,
equal
-
length
,
then
large
len
slice
//
-
decode
into
non
-
addressable
slice
of
equal
length
,
then
larger
len
//
-
for
each
decode
,
compare
elem
-
by
-
elem
to
the
original
slice
//
-
//
-
rinse
and
repeat
for
a
MapBySlice
version
//
-
*/}}
var
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
[]{{
.
Elem
}}
v
{{$
i
}}
v1
=
v
bs
{{$
i
}}
:=
testMarshalErr
(
v
{{$
i
}}
v1
,
h
,
t
,
"enc-slice-v{{$i}}"
)
if
v
==
nil
{
v
{{$
i
}}
v2
=
nil
}
else
{
v
{{$
i
}}
v2
=
make
([]{{
.
Elem
}},
len
(
v
))
}
testUnmarshalErr
(
v
{{$
i
}}
v2
,
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-slice-v{{$i}}"
)
if
v
==
nil
{
v
{{$
i
}}
v2
=
nil
}
else
{
v
{{$
i
}}
v2
=
make
([]{{
.
Elem
}},
len
(
v
))
}
testUnmarshalErr
(
reflect
.
ValueOf
(
v
{{$
i
}}
v2
),
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}-noaddr"
)
//
non
-
addressable
value
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-slice-v{{$i}}-noaddr"
)
//
...
bs
{{$
i
}}
=
testMarshalErr
(&
v
{{$
i
}}
v1
,
h
,
t
,
"enc-slice-v{{$i}}-p"
)
v
{{$
i
}}
v2
=
nil
testUnmarshalErr
(&
v
{{$
i
}}
v2
,
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}-p"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-slice-v{{$i}}-p"
)
v
{{$
i
}}
va
=
[
8
]{{
.
Elem
}}{}
//
clear
the
array
v
{{$
i
}}
v2
=
v
{{$
i
}}
va
[:
1
:
1
]
testUnmarshalErr
(&
v
{{$
i
}}
v2
,
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}-p-1"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-slice-v{{$i}}-p-1"
)
v
{{$
i
}}
va
=
[
8
]{{
.
Elem
}}{}
//
clear
the
array
v
{{$
i
}}
v2
=
v
{{$
i
}}
va
[:
len
(
v
{{$
i
}}
v1
):
len
(
v
{{$
i
}}
v1
)]
testUnmarshalErr
(&
v
{{$
i
}}
v2
,
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}-p-len"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-slice-v{{$i}}-p-len"
)
v
{{$
i
}}
va
=
[
8
]{{
.
Elem
}}{}
//
clear
the
array
v
{{$
i
}}
v2
=
v
{{$
i
}}
va
[:]
testUnmarshalErr
(&
v
{{$
i
}}
v2
,
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}-p-cap"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-slice-v{{$i}}-p-cap"
)
if
len
(
v
{{$
i
}}
v1
)
>
1
{
v
{{$
i
}}
va
=
[
8
]{{
.
Elem
}}{}
//
clear
the
array
testUnmarshalErr
((&
v
{{$
i
}}
va
)[:
len
(
v
{{$
i
}}
v1
)],
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}-p-len-noaddr"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
va
[:
len
(
v
{{$
i
}}
v1
)],
t
,
"equal-slice-v{{$i}}-p-len-noaddr"
)
v
{{$
i
}}
va
=
[
8
]{{
.
Elem
}}{}
//
clear
the
array
testUnmarshalErr
((&
v
{{$
i
}}
va
)[:],
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}-p-cap-noaddr"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
va
[:
len
(
v
{{$
i
}}
v1
)],
t
,
"equal-slice-v{{$i}}-p-cap-noaddr"
)
}
//
...
var
v
{{$
i
}}
v3
,
v
{{$
i
}}
v4
{{
.
MethodNamePfx
"typMbs"
false
}}
v
{{$
i
}}
v2
=
nil
if
v
!= nil { v{{$i}}v2 = make([]{{ .Elem }}, len(v)) }
v
{{$
i
}}
v3
=
{{
.
MethodNamePfx
"typMbs"
false
}}(
v
{{$
i
}}
v1
)
v
{{$
i
}}
v4
=
{{
.
MethodNamePfx
"typMbs"
false
}}(
v
{{$
i
}}
v2
)
bs
{{$
i
}}
=
testMarshalErr
(
v
{{$
i
}}
v3
,
h
,
t
,
"enc-slice-v{{$i}}-custom"
)
testUnmarshalErr
(
v
{{$
i
}}
v4
,
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}-custom"
)
testDeepEqualErr
(
v
{{$
i
}}
v3
,
v
{{$
i
}}
v4
,
t
,
"equal-slice-v{{$i}}-custom"
)
bs
{{$
i
}}
=
testMarshalErr
(&
v
{{$
i
}}
v3
,
h
,
t
,
"enc-slice-v{{$i}}-custom-p"
)
v
{{$
i
}}
v2
=
nil
v
{{$
i
}}
v4
=
{{
.
MethodNamePfx
"typMbs"
false
}}(
v
{{$
i
}}
v2
)
testUnmarshalErr
(&
v
{{$
i
}}
v4
,
bs
{{$
i
}},
h
,
t
,
"dec-slice-v{{$i}}-custom-p"
)
testDeepEqualErr
(
v
{{$
i
}}
v3
,
v
{{$
i
}}
v4
,
t
,
"equal-slice-v{{$i}}-custom-p"
)
}
{{
end
}}{{
end
}}{{
end
}}
}
func
doTestMammothMaps
(
t
*
testing
.
T
,
h
Handle
)
{
{{
range
$
i
,
$
e
:=
.
Values
}}{{
if
not
.
Primitive
}}{{
if
.
MapKey
}}{{/*
*/}}
for
_
,
v
:=
range
[]
map
[{{
.
MapKey
}}]{{
.
Elem
}}{
nil
,
{},
{
{{
nonzerocmd
.
MapKey
}}:{{
zerocmd
.
Elem
}}
{{
if
ne
"bool"
.
MapKey
}},
{{
nonzerocmd
.
MapKey
}}:{{
nonzerocmd
.
Elem
}}
{{
end
}}
}
}
{
//
fmt
.
Printf
(
">>>> running mammoth map v{{$i}}: %v
\n
"
,
v
)
var
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
map
[{{
.
MapKey
}}]{{
.
Elem
}}
v
{{$
i
}}
v1
=
v
bs
{{$
i
}}
:=
testMarshalErr
(
v
{{$
i
}}
v1
,
h
,
t
,
"enc-map-v{{$i}}"
)
if
v
==
nil
{
v
{{$
i
}}
v2
=
nil
}
else
{
v
{{$
i
}}
v2
=
make
(
map
[{{
.
MapKey
}}]{{
.
Elem
}},
len
(
v
))
}
//
reset
map
testUnmarshalErr
(
v
{{$
i
}}
v2
,
bs
{{$
i
}},
h
,
t
,
"dec-map-v{{$i}}"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-map-v{{$i}}"
)
if
v
==
nil
{
v
{{$
i
}}
v2
=
nil
}
else
{
v
{{$
i
}}
v2
=
make
(
map
[{{
.
MapKey
}}]{{
.
Elem
}},
len
(
v
))
}
//
reset
map
testUnmarshalErr
(
reflect
.
ValueOf
(
v
{{$
i
}}
v2
),
bs
{{$
i
}},
h
,
t
,
"dec-map-v{{$i}}-noaddr"
)
//
decode
into
non
-
addressable
map
value
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-map-v{{$i}}-noaddr"
)
if
v
==
nil
{
v
{{$
i
}}
v2
=
nil
}
else
{
v
{{$
i
}}
v2
=
make
(
map
[{{
.
MapKey
}}]{{
.
Elem
}},
len
(
v
))
}
//
reset
map
testUnmarshalErr
(&
v
{{$
i
}}
v2
,
bs
{{$
i
}},
h
,
t
,
"dec-map-v{{$i}}-p-len"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-map-v{{$i}}-p-len"
)
bs
{{$
i
}}
=
testMarshalErr
(&
v
{{$
i
}}
v1
,
h
,
t
,
"enc-map-v{{$i}}-p"
)
v
{{$
i
}}
v2
=
nil
testUnmarshalErr
(&
v
{{$
i
}}
v2
,
bs
{{$
i
}},
h
,
t
,
"dec-map-v{{$i}}-p-nil"
)
testDeepEqualErr
(
v
{{$
i
}}
v1
,
v
{{$
i
}}
v2
,
t
,
"equal-map-v{{$i}}-p-nil"
)
//
...
if
v
==
nil
{
v
{{$
i
}}
v2
=
nil
}
else
{
v
{{$
i
}}
v2
=
make
(
map
[{{
.
MapKey
}}]{{
.
Elem
}},
len
(
v
))
}
//
reset
map
var
v
{{$
i
}}
v3
,
v
{{$
i
}}
v4
{{
.
MethodNamePfx
"typMap"
false
}}
v
{{$
i
}}
v3
=
{{
.
MethodNamePfx
"typMap"
false
}}(
v
{{$
i
}}
v1
)
v
{{$
i
}}
v4
=
{{
.
MethodNamePfx
"typMap"
false
}}(
v
{{$
i
}}
v2
)
bs
{{$
i
}}
=
testMarshalErr
(
v
{{$
i
}}
v3
,
h
,
t
,
"enc-map-v{{$i}}-custom"
)
testUnmarshalErr
(
v
{{$
i
}}
v4
,
bs
{{$
i
}},
h
,
t
,
"dec-map-v{{$i}}-p-len"
)
testDeepEqualErr
(
v
{{$
i
}}
v3
,
v
{{$
i
}}
v4
,
t
,
"equal-map-v{{$i}}-p-len"
)
}
{{
end
}}{{
end
}}{{
end
}}
}
func
doTestMammothMapsAndSlices
(
t
*
testing
.
T
,
h
Handle
)
{
doTestMammothSlices
(
t
,
h
)
doTestMammothMaps
(
t
,
h
)
}
This diff is collapsed.
Click to expand it.
vendor/github.com/ugorji/go/codec/mammoth2-test.go.tmpl
0 → 100644
+
94
-
0
View file @
b627c550
//
+
build
!notfastpath
//
Copyright
(
c
)
2012
-
2015
Ugorji
Nwoke
.
All
rights
reserved
.
//
Use
of
this
source
code
is
governed
by
a
MIT
license
found
in
the
LICENSE
file
.
//
Code
generated
from
mammoth2
-
test
.
go
.
tmpl
-
DO
NOT
EDIT
.
package
codec
//
Increase
codecoverage
by
covering
all
the
codecgen
paths
,
in
fast
-
path
and
gen
-
helper
.
go
....
//
//
Add
:
//
-
test
file
for
creating
a
mammoth
generated
file
as
_mammoth_generated
.
go
//
-
generate
a
second
mammoth
files
in
a
different
file
:
mammoth2_generated_test
.
go
//
-
mammoth
-
test
.
go
.
tmpl
will
do
this
//
-
run
codecgen
on
it
,
into
mammoth2_codecgen_generated_test
.
go
(
no
build
tags
)
//
-
as
part
of
TestMammoth
,
run
it
also
//
-
this
will
cover
all
the
codecgen
,
gen
-
helper
,
etc
in
one
full
run
//
-
check
in
mammoth
*
files
into
github
also
//
-
then
//
//
Now
,
add
some
types
:
//
-
some
that
implement
BinaryMarshal
,
TextMarshal
,
JSONMarshal
,
and
one
that
implements
none
of
it
//
-
create
a
wrapper
type
that
includes
TestMammoth2
,
with
it
in
slices
,
and
maps
,
and
the
custom
types
//
-
this
wrapper
object
is
what
we
work
encode
/
decode
(
so
that
the
codecgen
methods
are
called
)
//
import
"encoding/binary"
import
"fmt"
type
TestMammoth2
struct
{
{{
range
.
Values
}}{{
if
.
Primitive
}}{{/*
*/}}{{
.
MethodNamePfx
"F"
true
}}
{{
.
Primitive
}}
{{
.
MethodNamePfx
"Fptr"
true
}}
*{{
.
Primitive
}}
{{
end
}}{{
end
}}
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
not
.
MapKey
}}{{/*
*/}}{{
.
MethodNamePfx
"F"
false
}}
[]{{
.
Elem
}}
{{
.
MethodNamePfx
"Fptr"
false
}}
*[]{{
.
Elem
}}
{{
end
}}{{
end
}}{{
end
}}
{{
range
.
Values
}}{{
if
not
.
Primitive
}}{{
if
.
MapKey
}}{{/*
*/}}{{
.
MethodNamePfx
"F"
false
}}
map
[{{
.
MapKey
}}]{{
.
Elem
}}
{{
.
MethodNamePfx
"Fptr"
false
}}
*
map
[{{
.
MapKey
}}]{{
.
Elem
}}
{{
end
}}{{
end
}}{{
end
}}
}
//
-----------
type
testMammoth2Binary
uint64
func
(
x
testMammoth2Binary
)
MarshalBinary
()
(
data
[]
byte
,
err
error
)
{
data
=
make
([]
byte
,
8
)
bigen
.
PutUint64
(
data
,
uint64
(
x
))
return
}
func
(
x
*
testMammoth2Binary
)
UnmarshalBinary
(
data
[]
byte
)
(
err
error
)
{
*
x
=
testMammoth2Binary
(
bigen
.
Uint64
(
data
))
return
}
type
testMammoth2Text
uint64
func
(
x
testMammoth2Text
)
MarshalText
()
(
data
[]
byte
,
err
error
)
{
data
=
[]
byte
(
fmt
.
Sprintf
(
"%b"
,
uint64
(
x
)))
return
}
func
(
x
*
testMammoth2Text
)
UnmarshalText
(
data
[]
byte
)
(
err
error
)
{
_
,
err
=
fmt
.
Sscanf
(
string
(
data
),
"%b"
,
(*
uint64
)(
x
))
return
}
type
testMammoth2Json
uint64
func
(
x
testMammoth2Json
)
MarshalJSON
()
(
data
[]
byte
,
err
error
)
{
data
=
[]
byte
(
fmt
.
Sprintf
(
"%v"
,
uint64
(
x
)))
return
}
func
(
x
*
testMammoth2Json
)
UnmarshalJSON
(
data
[]
byte
)
(
err
error
)
{
_
,
err
=
fmt
.
Sscanf
(
string
(
data
),
"%v"
,
(*
uint64
)(
x
))
return
}
type
testMammoth2Basic
[
4
]
uint64
type
TestMammoth2Wrapper
struct
{
V
TestMammoth2
T
testMammoth2Text
B
testMammoth2Binary
J
testMammoth2Json
C
testMammoth2Basic
M
map
[
testMammoth2Basic
]
TestMammoth2
L
[]
TestMammoth2
A
[
4
]
int64
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help