


객체 마스크에 지정되었음에도 불구하고 Go에서 GetConfiguration API 호출을 사용할 때 itemCategory 필드가 비어 있는 이유는 무엇입니까?
Go의 GetConfiguration API 호출에서 항목 범주 정보를 검색할 수 없습니다
REST API 호출
GET https://api.softlayer.com/rest/v3/SoftLayer_Product_Package/257/getConfiguration?objectMask=mask[itemCategory]
이 채워집니다. 다음 샘플 출력에 표시된 대로 반환된 Product_Package_Order_Configuration 객체의 itemCategory 필드:
{ "id": 7167, "isRequired": 0, "itemCategoryId": 390, "orderStepId": 1, "packageId": 257, "sort": 0, "itemCategory": { "categoryCode": "trusted_platform_module", "id": 390, "name": "Server Security", "quantityLimit": 1, "sortOrder": 0 } }
그러나 Go 프로그래밍 언어를 사용하여 동일한 호출을 수행하는 경우 itemCategory는 객체 마스크에 지정되었음에도 불구하고 비어 있습니다. , 다음 코드 조각에 설명된 대로:
package main import ( "fmt" "encoding/json" "github.com/softlayer/softlayer-go/session" "github.com/softlayer/softlayer-go/services" ) func main() { username := "set-me" apikey := "set-me" sess := session.New(username, apikey) sess.Debug = true service := services.GetProductPackageService(sess) mask := "itemCategory" result, err := service.Mask(mask).Id(257).GetConfiguration() if err != nil { fmt.Printf("\n Unable to retrieve config:\n - %s\n", err) return } jsonFormat, jsonErr := json.MarshalIndent(result, "", " ") if jsonErr != nil { fmt.Println(jsonErr) return } fmt.Println(string(jsonFormat)) }
샘플 출력에서는 itemCategory 필드가 개체 마스크에 포함되어 있음에도 불구하고 채워지지 않음을 보여줍니다.
Sample entry: { "id": 7167, "isRequired": 0, "itemCategoryId": 390, "orderStepId": 1, "packageId": 257, "sort": 0 }
해결 방법:
이 문제는 REST와 XMLRPC 끝점 간의 불일치로 인해 발생합니다. 제공된 코드는 도메인, 사용자 및 apiKey 매개변수의 존재로 표시된 대로 현재 XMLRPC 엔드포인트에 대해 구성되어 있습니다. REST 엔드포인트를 사용하려면 코드에서 이 섹션을
sess := session.New(username, apikey)
다음으로 바꾸세요.
endpoint := "https://api.softlayer.com/rest/v3" sess := session.New(username, apikey, endpoint)
REST 엔드포인트를 사용하면 의도한 대로 itemCategory 정보에 액세스할 수 있습니다.
위 내용은 객체 마스크에 지정되었음에도 불구하고 Go에서 GetConfiguration API 호출을 사용할 때 itemCategory 필드가 비어 있는 이유는 무엇입니까?의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

WhentestinggocodewithInitFunctions, useExplicitSetUpFunctionsOrsParateTestOvoiddenceNInItfictionSideffects.1) useExplicitSetUpFunctoControlGlobalVariableInitialization.2) CreateSeparateTesteSpilestobySinitFunctions 및 testesten

go'serrorhandlingreturnserrorsvalues whithuseexceptions와 달리 1) Go'sMethodensuresexpliciterRorhandling, promotingrobustcodebutincreasingverbosity.2) Javaandthon'sexextionslowercodebutcodebutcodebutcanlederforlortorifneterfortorifneteriflerortorifnetrorirederiflofertorifneateRoferfortoriflogertoflortoflerortofneateRofer

AneffectiveInterfaceingoisminimal, Clear, and Promotesloosecoupling.1) Minimizetheinterfaceforflexibilityandeasofimplementation.2) usicfacesforabStractionToswapimementationswhangingCallingCode.3) DesignStabilitySUsingInterfacestomockDep

중앙 집중식 오류 처리는 GO 언어에서 코드의 가독성과 유지 가능성을 향상시킬 수 있습니다. 구현 방법 및 장점에는 다음이 포함됩니다. 1. 비즈니스 로직에서 별도의 오류 처리 로직 및 코드를 단순화합니다. 2. 중앙 처리로 오류 처리의 일관성을 확인하십시오. 3. 연기 및 복구를 사용하여 공황을 포착하고 처리하여 프로그램 견고성을 향상시킵니다.

Ingo, alternativestoinitFunctionsincustomInitializationFenctionsandsingletons.1) CustomInitializationFunctionsallowExplicitControlover wheninInitializationOccurs, lexplodElayEdorConditionalSetUps.2) SingletEntensureOne-TimeInitializationIncOncurrent

gohandlesinterfacesandtypeassertionsefectively, codeflexibleandrobustness.1) typeSertionsOncaLownallowRuntImeTypeChecking, asseengehapeInterfaceAndCircLetype.2) TypeStwitchEshandleMultipleTypesePesePesePesePesePese -pervariousShapesimplementing Gry

GO 언어 오류 처리는 오류와 오류를 통해 더욱 유연하고 읽을 수 있습니다. 1.Errors.is는 오류가 지정된 오류와 동일한 지 확인하는 데 사용되며 오류 체인의 처리에 적합합니다. 2. 오류. 오류 유형을 확인할 수있을뿐만 아니라 오류를 특정 유형으로 변환 할 수 있으며 오류 정보 추출에 편리합니다. 이러한 기능을 사용하면 오류 처리 로직을 단순화 할 수 있지만 오류 체인의 올바른 전달에주의를 기울이고 코드 복잡성을 방지하기 위해 과도한 의존성을 피하십시오.

TomakeGoApplicationSRUNFASTERONDERFISTING, 사용 프로파일 링 툴, leverageConcurrency, andManageMemoryEffice.1) usepprofforcpuandMemoryProfingToIndifyBottLenecks.2) UtizeGoroutinesandChannelStoparAllelizetAskSandimProvePercormance.3) 3)


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

SublimeText3 영어 버전
권장 사항: Win 버전, 코드 프롬프트 지원!

안전한 시험 브라우저
안전한 시험 브라우저는 온라인 시험을 안전하게 치르기 위한 보안 브라우저 환경입니다. 이 소프트웨어는 모든 컴퓨터를 안전한 워크스테이션으로 바꿔줍니다. 이는 모든 유틸리티에 대한 액세스를 제어하고 학생들이 승인되지 않은 리소스를 사용하는 것을 방지합니다.

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기
