You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: 203. Remove Linked List Elements.go
    path of file: ./repos/LeetCode-Go/leetcode/0203.Remove-Linked-List-Elements
    
    the code of the file until where you have to start completion: package leetcode

import (
	"github.com/halfrost/LeetCode
    
func removeElements(head *ListNode, val int) *ListNode {
	if head == nil {
		return head
	}
	newHead := &ListNode{Val: 0, Next: head}
	pre := newHead
	cur := head
	for cur != nil {
		if cur.Val == val {
			pre.Next = cur.Next
		} else {
			pre = cur
		}
		cur = cur.Next
	}
	return newHead.Next
}