MCPcopy Create free account
hub / github.com/cloudwego/dynamicgo / buildBasicExampleJSONData

Function buildBasicExampleJSONData

conv/j2p/conv_test.go:443–475  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

441}
442
443func buildBasicExampleJSONData() error {
444 req := getBasicExampleReq()
445 data, err := json.Marshal(req)
446 if err != nil {
447 panic(fmt.Sprintf("buildExampleJSONData failed, err: %v", err.Error()))
448 }
449 checkExist := func(path string) bool {
450 _, err := os.Stat(path)
451 if err != nil {
452 if os.IsExist(err) {
453 return true
454 }
455 return false
456 }
457 return true
458 }
459 var file *os.File
460 absoluteExampleJSONPath := util_test.MustGitPath(basicExampleJSON)
461 if checkExist(absoluteExampleJSONPath) == true {
462 if err = os.Remove(absoluteExampleJSONPath); err != nil {
463 panic("delete protoJSONFile failed")
464 }
465 }
466 file, err = os.Create(absoluteExampleJSONPath)
467 if err != nil {
468 panic("create protoJSONFile failed")
469 }
470 defer file.Close()
471 if _, err := file.WriteString(string(data)); err != nil {
472 panic("write protoJSONData failed")
473 }
474 return nil
475}
476
477func getExampleInt2Float() *proto.TypeDescriptor {
478 includeDirs := util_test.MustGitPath("testdata/idl/") // includeDirs is used to find the include files.

Callers 1

Calls 6

MustGitPathFunction · 0.92
getBasicExampleReqFunction · 0.85
CloseMethod · 0.80
MarshalMethod · 0.45
ErrorMethod · 0.45
WriteStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…