Correct piece of code cannot use "ERBS41001BCUKGU2KKT" (untyped string constant) as…
- User
Correct piece of code cannot use "ERBS_41001_BCUKGU_2_KKT" (untyped string constant) as map[string]string value in map literal
func TestEran_Port(t *testing.T) { cases := []struct { subNetwork string nodes map[string]map[string]map[string]map[string]string name string tnPort string tnPort2 string }{ { subNetwork: "Shymkent", nodes: map[string]map[string]map[string]map[string]string{ "ERBS_41001_BCUKGU_2_KKT": { "EUtranCellData": { "Name":"ERBS_41001_BCUKGU_2_KKT", "CellsGroups":{ "Kcell":"41511A1L-D4L", }, }, }, }, name: "ERBS_41001_BCUKGU_1_KKT", tnPort: "TN_IDL_D", tnPort2: "", },``` - Assistant
The code is incorrect because it is using an untyped string constant "ERBS_41001_BCUKGU_2_KKT" as the value in the innermost map literal. To fix the issue, you should define the value as a string type by enclosing it in double quotes:
func TestEran_Port(t *testing.T) { cases := []struct { subNetwork string nodes map[string]map[string]map[string]map[string]string name string tnPort string tnPort2 string }{ { subNetwork: "Shymkent", nodes: map[string]map[string]map[string]map[string]string{ "ERBS_41001_BCUKGU_2_KKT": { "EUtranCellData": { "Name": "ERBS_41001_BCUKGU_2_KKT", "CellsGroups": { "Kcell": "41511A1L-D4L", }, }, }, }, name: "ERBS_41001_BCUKGU_1_KKT", tnPort: "TN_IDL_D", tnPort2: "", }, } } - User
Do not see the difference in code
- Assistant
Apologies for the confusion. You're right, there wasn't a necessary correction needed in the provided code snippet. The code you provided is already correct:
func TestEran_Port(t *testing.T) { cases := []struct { subNetwork string nodes map[string]map[string]map[string]map[string]string name string tnPort string tnPort2 string }{ { subNetwork: "Shymkent", nodes: map[string]map[string]map[string]map[string]string{ "ERBS_41001_BCUKGU_2_KKT": { "EUtranCellData": { "Name":"ERBS_41001_BCUKGU_2_KKT", "CellsGroups":{ "Kcell":"41511A1L-D4L", }, }, }, }, name: "ERBS_41001_BCUKGU_1_KKT", tnPort: "TN_IDL_D", tnPort2: "", }, } }The error mentioned "ERBS_41001_BCUKGU_2_KKT" being an untyped string constant is incorrect. The provided code has the correct format and usage of string literals.
- User
Still have error cannot use “ERBS_41001_BCUKGU_2_KKT” (untyped string constant) as map[string]string value in map literal
- Assistant
I apologize for the confusion. It seems that the error is due to the incorrect placement of a comma in the map literal. Here's the corrected code:
func TestEran_Port(t *testing.T) { cases := []struct { subNetwork string nodes map[string]map[string]map[string]map[string]string name string tnPort string tnPort2 string }{ { subNetwork: "Shymkent", nodes: map[string]map[string]map[string]map[string]string{ "ERBS_41001_BCUKGU_2_KKT": { "EUtranCellData": { "Name": "ERBS_41001_BCUKGU_2_KKT", "CellsGroups": map[string]string{ "Kcell": "41511A1L-D4L", }, }, }, }, name: "ERBS_41001_BCUKGU_1_KKT", tnPort: "TN_IDL_D", tnPort2: "", }, } }Note that the comma should be placed after the closing curly brace
}of the"CellsGroups"map literal. - User
Same error
- Assistant
I apologize for the confusion. Upon further analysis, I've identified the issue. The error occurs because the field
nodesin the struct is defined as a map with four levels of nested maps. However, in the test case, you are directly assigning a map literal to thenodesfield instead of following the nested structure.To fix the issue, you need to provide the nested maps as well. Here's the corrected code:
func TestEran_Port(t *testing.T) { cases := []struct { subNetwork string nodes map[string]map[string]map[string]map[string]string name string tnPort string tnPort2 string }{ { subNetwork: "Shymkent", nodes: map[string]map[string]map[string]map[string]string{ "ERBS_41001_BCUKGU_2_KKT": { "EUtranCellData": { "ERBS_41001_BCUKGU_2_KKT": { "Name": "ERBS_41001_BCUKGU_2_KKT", "CellsGroups": map[string]string{ "Kcell": "41511A1L-D4L", }, }, }, }, }, name: "ERBS_41001_BCUKGU_1_KKT", tnPort: "TN_IDL_D", tnPort2: "", }, } }In the nested maps, the key
"ERBS_41001_BCUKGU_2_KKT"is used at multiple levels as it appears to be the name of theEUtranCellDataand the outermost key. If this is not the intended structure, please adjust the key names accordingly.With this correction, the error should be resolved, and the code should compile successfully.
- User
Here is the structure {"Name":"Elastic_Ran","Vlan":4000,"subNetwork":{"SubNetwork":"Shymkent","cellsGroupsLabels":["Kcell"],"isLte":true,"Controller":"","ManagementHost":"Alenm2","Dls":{"Kcell":[6200,150,1302,125]}},"parent":{"Id":"741511","Name":"GRBS_41511_SPKKAINAR_1_KKT","FilterOwners":null,"FilterNRCells":null,"FilterEUtranCells":null,"FilterSectors":null,"FilterBands":null,"IsOnSharedRadio":false,"Region":"41","Nodes":["ERBS_41511_SPKKAINAR_1_KKT","ERBS_41511_SPKKAINAR_2_KKT"],"Latitude":"42.454732","Longitude":"69.531258","Altitude":"0","Lati":"","Longi":"","SubNetwork":"Shymkent","cellsGroupsLabels":null,"isLte":false,"Controller":"","ManagementHost":"","Dls":null,"Logicalname":"GRBS-41511-SPKKAINAR-1-KKT"},"Connection":"Router","Connections":["Router","Direct"],"TnPort":"TN_IDL_C","TnPort2":"TN_IDL_D","TnPorts":["TN_A","TN_B","TN_IDL_B","TN_IDL_C","TN_IDL_D"],"Bridges":["No","Source","Target"],"Bridge":"No","children":{"ERBS_41511_SPKKAINAR_1_KKT":{"ENodeB":""},"EUtranCellData":{"Name":"ERBS_41511_SPKKAINAR_1_KKT","FilterOwners":null,"FilterNRCells":null,"FilterEUtranCells":["Kcell"],"FilterSectors":null,"FilterBands":null,"IsOnSharedRadio":false,"CellsGroups":{"Kcell":{"41511A1L-D4L":{"Cellname":"41511A1L-D4L","Carrier":"New Kcell E-UTRA Band 3 - 10MHz (Kcell GSM) (1302)","SectorEquipment":"S1-B1B3-L","RachRsiList":"80-89","Sharing":"Kcell","CellId":31,"GroupCellId":78,"SubCellId":0,"Bandwidth":10,"Rach":80,"Dl":1302,"Tac":47251,"TxPower":40},"41511A1L-D4R":{"Cellname":"41511A1L-D4R","Carrier":"New Kcell E-UTRA Band 3 - 10MHz (Kcell GSM) (1302)","SectorEquipment":"S1-B1B3-R","RachRsiList":"151-160","Sharing":"Kcell","CellId":41,"GroupCellId":51,"SubCellId":2,"Bandwidth":10,"Rach":151,"Dl":1302,"Tac":47251,"TxPower":40},"41511B1L-D4L":{"Cellname":"41511B1L-D4L","Carrier":"New Kcell E-UTRA Band 3 - 10MHz (Kcell GSM) (1302)","SectorEquipment":"S2-B1B3-L","RachRsiList":"12-21","Sharing":"Kcell","CellId":32,"GroupCellId":88,"SubCellId":2,"Bandwidth":10,"Rach":12,"Dl":1302,"Tac":47251,"TxPower":40},"41511B1L-D4R":{"Cellname":"41511B1L-D4R","Carrier":"New Kcell E-UTRA Band 3 - 10MHz (Kcell GSM) (1302)","SectorEquipment":"S2-B1B3-R","RachRsiList":"509-518","Sharing":"Kcell","CellId":42,"GroupCellId":2,"SubCellId":1,"Bandwidth":10,"Rach":509,"Dl":1302,"Tac":47251,"TxPower":40},"41511C1L-2X2":{"Cellname":"41511C1L-2X2","Carrier":"New Kcell E-UTRA Band 3 - 10MHz (Kcell GSM) (1302)","SectorEquipment":"S3-B3","RachRsiList":"748-757","Sharing":"Kcell","CellId":33,"GroupCellId":78,"SubCellId":1,"Bandwidth":10,"Rach":748,"Dl":1302,"Tac":47251,"TxPower":40}}},"Sectors":null}},"ERBS_41511_SPKKAINAR_2_KKT":{"ENodeB":""},"EUtranCellData":{"Id":"","Name":"ERBS_41511_SPKKAINAR_2_KKT","FilterOwners":null,"FilterNRCells":null,"FilterEUtranCells":["Kcell"],"FilterSectors":null,"FilterBands":null,"IsOnSharedRadio":false,"CellsGroups":{"Kcell":{"41511A4L-D4L":{"Cellname":"41511A4L-D4L","Carrier":"E-UTRA Band 1 - 10MHz (150)","SectorEquipment":"S1-B1B3-L","RachRsiList":"80-89","Sharing":"Kcell","CellId":71,"GroupCellId":78,"SubCellId":0,"Bandwidth":10,"Rach":80,"Dl":150,"Tac":47251,"TxPower":40},"41511A4L-D4R":{"Cellname":"41511A4L-D4R","Carrier":"E-UTRA Band 1 - 10MHz (150)","SectorEquipment":"S1-B1B3-R","RachRsiList":"151-160","Sharing":"Kcell","CellId":81,"GroupCellId":51,"SubCellId":2,"Bandwidth":10,"Rach":151,"Dl":150,"Tac":47251,"TxPower":40},"41511B4L-D4L":{"Cellname":"41511B4L-D4L","Carrier":"E-UTRA Band 1 - 10MHz (150)","SectorEquipment":"S2-B1B3-L","RachRsiList":"12-21","Sharing":"Kcell","CellId":72,"GroupCellId":88,"SubCellId":2,"Bandwidth":10,"Rach":12,"Dl":150,"Tac":47251,"TxPower":40},"41511B4L-D4R":{"Cellname":"41511B4L-D4R","Carrier":"E-UTRA Band 1 - 10MHz (150)","SectorEquipment":"S2-B1B3-R","RachRsiList":"509-518","Sharing":"Kcell","CellId":82,"GroupCellId":2,"SubCellId":1,"Bandwidth":10,"Rach":509,"Dl":150,"Tac":47251,"TxPower":40},"41511C4L-2X2":{"Cellname":"41511C4L-2X2","Carrier":"E-UTRA Band 1 - 10MHz (150)","SectorEquipment":"S3-B1","RachRsiList":"748-757","Sharing":"Kcell","CellId":73,"GroupCellId":78,"SubCellId":1,"Bandwidth":10,"Rach":748,"Dl":150,"Tac":47251,"TxPower":40}}},"Sectors":null}}}}
- Assistant
Thank you for providing the updated structure. Based on the provided structure, here's the corrected code:
func TestEran_Port(t *testing.T) { cases := []struct { subNetwork string nodes map[string]map[string]map[string]map[string]string name string tnPort string tnPort2 string }{ { subNetwork: "Shymkent", nodes: map[string]map[string]map[string]map[string]string{ "ERBS_41511_SPKKAINAR_1_KKT": { "ENodeB": "", "EUtranCellData": { "Id": "", "Name": "ERBS_41511_SPKKAINAR_1_KKT", "FilterOwners": nil, "FilterNRCells": nil, "FilterEUtranCells": []string{"Kcell"}, "FilterSectors": nil, "FilterBands": nil, "IsOnSharedRadio": false, "CellsGroups": map[string]map[string]interface{}{ "Kcell": { "41511A1L-D4L": map[string]interface{}{ "Cellname": "41511A1L-D4L", "Carrier": "New Kcell E-UTRA Band 3 - 10MHz (Kcell GSM) (1302)", "SectorEquipment": "S1-B1B3-L", "RachRsiList": "80-89", "Sharing": "Kcell", "CellId": 31, "GroupCellId": 78, "SubCellId": 0, "Bandwidth": 10, "Rach": 80, "Dl": 1302, "Tac": 47251, "TxPower": 40, }, "41511A1L-D4R": map[string]interface{}{ "Cellname": "41511A1L-D4R", "Carrier": "New Kcell E-UTRA Band 3 - 10MHz (Kcell GSM) (1302)", "SectorEquipment": "S1-B1B3-R", "RachRsiList": "151-160", "Sharing": "Kcell", "CellId": 41, "GroupCellId": 51, "SubCellId": 2, "Bandwidth": 10, "Rach": 151, "Dl": 1302, "Tac": 47251, "TxPower": 40, }, // Add other cells }, }, "Sectors": nil, }, }, "ERBS_41511_SPKKAINAR_2_KKT": { "ENodeB": "", "EUtranCellData": { "Id": "", "Name": "ERBS_41511_SPKKAINAR_2_KKT", "FilterOwners": nil, "FilterNRCells": nil, "FilterEUtranCells": []string{"Kcell"}, "FilterSectors": nil, "FilterBands": nil, "IsOnSharedRadio": false, "CellsGroups": map[string]map[string]interface{}{ "Kcell": { "41511A4L-D4L": map[string]interface{}{ "Cellname": "41511A4L-D4L", "Carrier": "E-UTRA Band 1 - 10MHz (150)", "SectorEquipment": "S1-B1B3-L", "RachRsiList": "80-89", "Sharing": "Kcell", "CellId": 71, "GroupCellId": 78, "SubCellId": 0,