One of the 10 Commandments is “thou shall not kill”. Did this apply to young David when he basically told Goliath he was going to kill him? David made it perfectly clear what he was going to do.
The majority of both Jewish and Christian scholars have interpreted the commandment “You shall not kill” to be a commandment to not take the life of another out of anger or any other kind of personal motive. In other words it is equivalent to the commandment “You shall not murder.”
We know that this has to be the case, or at least something very similar to it because God commanded the Jews to take the Promised Land by force. To take a life as a member of a legitimate armed force or as a law enforcement officer is not necessarily wrong, at least if we use the Ten Commandments as a guide. If the commandment “You shall not kill” included the taking of a life in defense of a country or of the civil police, then there would be an obvious contradiction in the Bible. Romans 13:4 says that the government does not bear the sword in vain.
Whether a Christian ought to voluntarily enlist in the military of another position which might require them to take a life is a debatable point of Christian doctrine, but that the Jews had that right and that our governing authorities have that right is well established biblically.
This is how I would respond to what David said to Goliath. The armies which sought to destroy political Israel were the enemies of God and God’s people definitely had permission to defend Israel, which obviously would include the possibility of killing one of God’s enemies, such as Goliath.